#include <fstream>
using namespace std;
ifstream in("datorii.in");
ofstream out("datorii.out");
int tree[60020];
inline void build(int nod, int st, int dr, int x, int poz) {
if(st == dr) {
tree[nod] = x;
return;
}
int mij = (st + dr) / 2;
if(poz <= mij)
build((nod << 1), st, mij, x, poz);
else
build((nod << 1) + 1, mij + 1, dr, x, poz);
tree[nod] = tree[(nod << 1)] + tree[(nod << 1) + 1];
}
inline void update(int nod, int st, int dr, int poz, int x) {
if(st == dr) {
tree[nod] -= x;
return;
}
int mij = (st + dr) / 2;
if(poz <= mij)
update((nod << 1), st, mij, poz, x);
else
update((nod << 1) + 1, mij + 1, dr, poz, x);
tree[nod] = tree[(nod << 1)] + tree[(nod << 1) + 1];
}
inline int sum(int nod, int st, int dr, int poz_st, int poz_dr) {
if(poz_st > dr || poz_dr < st)
return 0;
if(poz_st <= st && dr <= poz_dr )
return tree[nod];
int mij = (st + dr) / 2;
return sum((nod << 1), st, mij, poz_st, poz_dr) + sum((nod << 1) + 1, mij + 1, dr, poz_st, poz_dr);
}
int main() {
int n, m, x, y, op;
in >> n >> m;
for(int i = 1; i <= n; i++) {
in >> x;
build(1, 1, n, x, i);
}
for(int i = 1; i <= m; i++){
in >> op >> x >> y;
if(op == 0)
update(1, 1, n, x, y);
else
out << sum(1, 1, n, x, y) << '\n';
}
return 0;
}