#include <iostream>
#include <fstream>
using namespace std;
ifstream fin("datorii.in");
ofstream fout("datorii.out");
int n, q;
int v[61000];
int ask(int nod, int st, int dr, int a, int b) {
if (a <= st && dr <= b)
return v[nod];
int mij = (st + dr) / 2;
int toReturn = 0;
if (a <= mij)
toReturn += ask(2 * nod, st, mij, a, b);
if (b >= mij + 1)
toReturn += ask(2 * nod + 1, mij + 1, dr, a, b);
return toReturn;
}
void update(int nod, int st, int dr, int pos, int value) {
if (st == pos && pos == dr) {
v[nod] = value;
return;
}
int mij = (st + dr) / 2;
if (pos <= mij)
update(2 * nod, st, mij, pos, value);
else
update(2 * nod + 1, mij + 1, dr, pos, value);
v[nod] = v[2 * nod] + v[2 * nod + 1];
}
void readAndSet() {
fin >> n >> q;
for (int i = 1; i <= n; i++) {
int nr;
fin >> nr;
update(1, 1, n, i, nr);
}
}
void ansQueries() {
while (q--) {
int c, a, b;
fin >> c >> a >> b;
if (c == 0) {
int newValue = ask(1, 1, n, a, a) - b;
update(1, 1, n, a, newValue);
} else
fout << ask(1, 1, n, a, b) << '\n';
}
}
int main() {
readAndSet();
ansQueries();
return 0;
}