using namespace std;
#include <cstdio>
int tree[1<<17],n,nn;
void Add(int poz, int valoare){
int tmp,q;
while(poz<=n){
tree[poz] += valoare;
tmp=poz;q=1;
while(!(tmp&1)) q<<=1, tmp >>=1;
poz+=q;
}
for(int i=1;i<=n;i++)
printf("%d ",tree[i]);
printf("\n");
}
int Sum(int st,int dr){
if(st>1)
return Sum(1, dr) - Sum(1,st-1);
int s=0,tmp,q,poz=dr;
while(poz){
s+=tree[poz];
tmp=poz;q=1;
while(!(tmp&1)) q<<=1, tmp >>=1;
poz -= q;
}
return s;
}
int Pozitie(int suma){
if(suma<tree[1] || suma>tree[n])
return -1;
if(suma==tree[1])
return 1;
if(suma==tree[n])
return nn;
int st=1,dr=n;
while(st<dr){
int mijloc = (st+dr)>>1;
if(suma == tree[mijloc])
return mijloc;
if(suma < tree[mijloc])
dr = mijloc;
else
suma -= tree[mijloc], st = mijloc;
}
return -1;
}
int main(){
FILE *f=fopen("aib.in","r");
FILE *g=fopen("aib.out","w");
int m,a,b,op;
fscanf(f,"%d%d",&nn,&m);
n=1;
while(n<nn)
n<<=1;
for(int i=1;i<=nn;i++){
fscanf(f,"%d",&a);
Add(i,a);
}
for( ; m ; --m){
fscanf(f,"%d",&op);
if(op == 2){
fscanf(f,"%d",&a);
fprintf(g,"%d\n",Pozitie(a));
}
else{
fscanf(f,"%d%d", &a,&b);
if(op==0)
Add(a,b);
else
fprintf(g,"%d\n",Sum(a,b));
}
}
return 0;
}