#include <fstream>
using namespace std;
ifstream cin("datorii.in");
ofstream cout("datorii.out");
int n,m,i,t,x,y,sum,mij;
int AIB[400004];
void query(int nod,int l,int r,int st,int dr)
{
if (st<=l and r<=dr)
{
sum+=AIB[nod];
return;
}
int mij=(l+r)>>1;
if (st<=mij) query(nod*2,l,mij,st,dr);
if (dr>mij) query(nod*2+1,mij+1,r,st,dr);
}
void build(int nod, int st, int dr, int poz, int val)
{
if(st == dr)
{
AIB[nod] = val;
return ;
}
int mij = (st + dr) / 2;
if(poz < mij) build(2 * nod, st, mij, poz, val);
else build(2 * nod + 1, mij + 1, dr, poz, val);
AIB[nod]=AIB[nod*2]+AIB[nod*2+1];
}
void update(int nod, int st, int dr, int poz, int val)
{
if(st == dr)
{
AIB[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);
AIB[nod]=AIB[nod*2]+AIB[nod*2+1];
}
int main()
{
fin>>n>>m;
for (i=1;i<=n;i++)
cin>>x,
build(1, 1, n, i, x);
for (i=1;i<=m;i++)
{
cin>>t>>x>>y;
if (t==1)
{
sum = 0;
query (1,1,n,x,y);
cout << sum <<"\n";
}
if (t==0) // primul 1 este pentru nodul cel mai de jos
// 1 si n sunt capetele grafului
update(1,1,n,x,y); // elementul de pe pozitia x primeste valoarea y
}
}