#include <iostream>
#include <fstream>
using namespace std;
std::ifstream f("datorii.in");
std::ofstream g("datorii.out");
int t[60100];
void update(int nod, int st, int dr, int poz, int val)
{
if(st==dr)
{
t[nod]=val;
return;
}
int mij = (st+dr)/2;
if(poz<=mij) update(2*nod,st,mij,poz,val);
else update(2*nod+1,mij+1,dr,poz,val);
t[nod] = t[2*nod] + t[2*nod+1];
}
void update2(int nod, int st, int dr, int poz, int val)
{
if(st==dr)
{
t[nod]-=val;
return;
}
int mij = (st+dr)/2;
if(poz<=mij) update2(2*nod,st,mij,poz,val);
else update2(2*nod+1,mij+1,dr,poz,val);
t[nod] = t[2*nod] + t[2*nod+1];
}
int getmax(int nod, int st, int dr, int l, int r)
{
if(l<=st && dr<=r) return t[nod];
int ret = 0;
int mij = (st+dr)/2;
if(r>mij) ret = ret + getmax(nod*2+1,1+mij,dr,l,r);
if(l<=mij) ret = ret + getmax(nod*2,st,mij,l,r);
return ret;
}
int main()
{
int n, m;
f >> n >> m;
for(int i=1;i<=n;i++){
int x;
f >> x;
update(1,1,n,i,x);
}
for(int i = 1; i <= m; i++){
int op, a, b;
f >> op >> a >> b;
if( op == 0) update2(1,1,n,a,b);
else g << getmax(1,1,n,a,b) << "\n";
}
}