#include <fstream>
using namespace std;
ifstream cin ("datorii.in");
ofstream cout ("datorii.out");
int st[60000], v[15005];
void update(int to, int from, int pos, int val, int node) {
if(to == from) {
st[node] = val;
return;
}
int mid = (from+to)/2;
if(pos <= mid)
update(mid, from, pos, val, node*2);
else update(to, mid+1, pos, val, node*2+1);
st[node] = st[2*node]+st[2*node+1];
}
int query(int from, int to, int node, int ql, int qr) {
if(ql <= from && to <= qr)
return st[node];
int mid = (to+from)/2, s = 0;
if(ql <= mid)
s += query(from, mid, node*2, ql, qr);
if(mid+1 <= qr)
s += query(mid+1, to, node*2+1, ql, qr);
return s;
}
signed main() {
int n,q;
cin >> n >> q;
for(int i = 1; i <= n; i++) {
cin >> v[i];
update(n, 1, i, v[i], 1);
}
int cer, a, b;
while(q--) {
cin >> cer >> a >> b;
if(cer == 0)
update(n, 1, a, v[a] - b, 1), v[a] -= b;
else cout << query(1, n, 1, a, b) << '\n';
}
}