#include <iostream>
#include <bits/stdc++.h>
using namespace std;
ifstream f ("datorii.in");
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;
int x;
for (int i = 0; i < n; i++)
{
f >> x;
update(1,1,n,i+1,x);
}
for (int i = 0; i < m; i++)
{
int o;
f >> o;
if (o == 0)
{
int poz,val;
f >> poz >> val;
update2(1,1,n,poz,val);
}
else
{
int p1, p2;
f >> p1 >> p2;
g << getmax(1, 1, n, p1, p2) << '\n';
}
}
return 0;
}