#include <bits/stdc++.h>
using namespace std;
ifstream fin("datorii.in");
ofstream fout("datorii.out");
struct node{
int sumar=0;
node *left=NULL,*right=NULL;
};
node *rad;
std::vector<int> v;
int n,m;
void build(node* nod,int l,int r){
if(l==r){
nod->sumar=v[l];
}else{
int mij=(l+r)/2;
if(nod->left==NULL)
{
nod->left=new node;
build(nod->left,l,mij);
}
if(nod->right==NULL){
nod->right=new node;
build(nod->right,mij+1,r);
}
nod->sumar=nod->left->sumar+nod->right->sumar;
}
}
int solve0(node *nod,int l,int r,int x,int y){
if(x<=l && r<=y)
return nod->sumar;
else {
int m=(l+r)/2;
int solleft=0,solright=0;
if(x<=m)
solleft=solve0(nod->left,l,m,x,y);
if(y>m)
solright=solve0(nod->right,m+1,r,x,y);
return solleft+solright;
}
}
void update(node *nod,int l,int r,int x,int y){
if(l==r && l==x)
{
nod->sumar-=y;
}else{
int mij=(l+r)/2;
if(x<=mij)
{
update(nod->left,l,mij,x,y);
}else{
update(nod->right,mij+1,r,x,y);
}
int valmax=0;
if(nod->left!=NULL)
valmax=valmax+nod->left->sumar;
if(nod->right!=NULL)
valmax=valmax+nod->right->sumar;
nod->sumar=valmax;
}
}
int main(int argc, char const *argv[]) {
fin>>n>>m;
v.resize(n+1);
for(int i=1;i<=n;i++){
fin>>v[i];
}
rad=new node;
build(rad,1,n);
int op,x,y;
for(int i=1;i<=m;i++){
fin>>op>>x>>y;
if(op==0){
update(rad,1,n,x,y);
}else {//op==1
fout<<solve0(rad,1,n,x,y)<<'\n';
}
}
return 0;
}