#include <iostream>
#include <fstream>
#define inf 2000
using namespace std;
ifstream in ("datorii.in");
ofstream out ("datorii.out");
const int N=1<<17;
const int nmax=15001;
int t[N],v[nmax],a,b,poz,val,sum;
void actualizare (int p, int st, int dr)
{
///t[p] retine max (v[st],v[st+1],...,v[dr])
if (st==dr)
{
t[p]=t[p]-val;
return;
}
int m=(st+dr)/2;
if (poz<=m)
{
actualizare (2*p,st,m);
}
else
{
actualizare (2*p+1,m+1,dr);
}
t[p]=t[2*p]+t[2*p+1];
}
int interogare (int p, int st, int dr)
{
///returnez max din [a,b]^[st,dr]
if (a<=st && dr<=b) ///intersectia e chiar [st,dr]
{
return t[p];
}
int m=(st+dr)/2;
int m1=0,m2=0;
if (a<=m)
{
m1=interogare (p*2,st,m);
}
if (b>m)
{
m2=interogare (p*2+1,m+1,dr);
}
return m1+m2;
}
void construct (int p, int st, int dr)
{
if (st==dr)
{
t[p]=v[st];
return;
}
int m=(st+dr)/2;
construct (p*2,st,m);
construct (p*2+1,m+1,dr);
t[p]=t[p*2]+t[p*2+1];
}
int main()
{
int n,m,cod,x,y;
in>>n>>m;
for (int i=1;i<=n;i++)
in>>v[i];
construct (1,1,n);
for (int i=1;i<=m;i++)
{
in>>cod;
if (cod==0)
{
in>>poz>>val;
actualizare (1,1,n);
}
else
{
in>>a>>b;
out<<interogare (1,1,n)<<'\n';
}
}
return 0;
}