#include <iostream>
#include <fstream>
using namespace std;
ifstream f("datorii.in");
ofstream g("datorii.out");
int N, M, arbore[450000], sir[15001], r;
int adaug(int nod, int st, int dr) {
if (st == dr) {
arbore[nod] = sir[st];
return arbore[nod];
}
int mijloc = (st + dr)/2, a, b;
a = adaug(2 * nod, st, mijloc);
b = adaug(2 * nod + 1, mijloc + 1, dr);
arbore[nod] = a + b;
return arbore[nod];
}
void update(int nod, int st, int dr, int x, int i) {
if (st == dr) {
arbore[nod] = x;
sir[st] = x;
return;
}
int mijloc = (st + dr)/2;
if (i <= mijloc) update(2 * nod, st, mijloc, x, i);
else update(2 * nod + 1, mijloc + 1, dr, x, i);
arbore[nod] = arbore[2 * nod + 1] + arbore[2 * nod];
}
int query(int nod, int st, int dr, int a, int b)
{
int mijloc = (st + dr)/2;
if(a > dr || st > b) return 0;
if(a <= st && dr <= b) return arbore[nod];
int x = query(2 * nod, st, mijloc, a, b);
int y = query(2 * nod + 1, mijloc + 1, dr, a, b);
return x + y;
}
int main()
{
f >> N >> M;
for (int i = 1; i <= N; i++)
f >> sir[i];
adaug(1, 1, N);
for (int i = 1; i <= M; i++) {
int tip, a, b;
f >> tip >> a >> b;
if (tip == 0) update(1, 1, N, sir[a] - b, a);
else {
r = 0;
r = query(1, 1, N, a, b);
g << r << '\n';
}
}
return 0;
}