#include <fstream>
#define nmax 15001
using namespace std;
fstream f1("datorii.in", ios::in);
fstream f2("datorii.out", ios::out);
int16_t n;
int32_t m;
int32_t v[nmax], aint[nmax];
void citire()
{
int32_t i;
f1>>n>>m;
for(i=1; i<=n; i++)
f1>>v[i];
}
void creare(int32_t poz, int32_t st, int32_t dr)
{
if(st<dr)
{
int32_t mijl=(st+dr)/2;
creare(poz*2, st, mijl);
creare(poz*2+1, mijl+1, dr);
aint[poz]=aint[poz*2]+aint[2*poz+1];
}
else if(st==dr)
{
aint[poz]=v[st];
}
}
void update(int32_t poz, int32_t st, int32_t dr, int32_t sc, int32_t val)
{
if(st<dr)
{
int32_t mijl=(st+dr)/2;
if(sc<=mijl) update(poz*2, st, mijl, sc, val);
else update(poz*2+1, mijl+1, dr, sc, val);
aint[poz]=aint[poz*2]+aint[poz*2+1];
}
else if(st==dr)
{
aint[poz]-=val;///poz=sc
}
}
int32_t suma(int32_t poz, int32_t st, int32_t dr, int32_t a, int32_t b)
{
///a-b interval de compus
if((a<=st)&&(dr<=b)) return aint[poz];
else
{
int32_t mijl=(st+dr)/2, max1=0, max2=0;
if(a<=mijl)
{
max1=suma(poz*2, st, mijl, a, b);
}
if(b>mijl)
{
max2=suma(poz*2+1, mijl+1, dr, a, b);
}
return (max1+max2);
}
}
void intrebari()
{
int32_t i, x, y, op;
for(i=1; i<=m; i++)
{
f1>>op>>x>>y;
if(op==0) update(1, 1, n, x, y);
else f2<<suma(1, 1, n, x, y)<<"\n";
}
}
int main()
{
citire();
creare(1, 1, n);
intrebari();
return 0;
}