#include<stdio.h>
#include<string.h>
FILE *f=fopen("aib.in","r"), *g=fopen("aib.out","w");
int n,m,arbore[100001],i,x,k,a,b;
void update(int pos, int val)
{
int zero=0;
while(pos<=n)
{
arbore[pos]+=val;
while(!(pos&(1<<zero))) zero++;
pos+=1<<zero;
zero++;
}
}
inline int query(int pos)
{
int zero=0,suma2=0;
while(pos){
suma2+=arbore[pos];
while(!(pos&(1<<zero))) zero++;
pos-=1<<zero;
zero++;
}
return suma2;
}
int cautare(int suma)
{
int pos=n+1,Q,S=0;
int st=0,dr=n+1;
Q=n;
S=query(Q);
if(S==suma) pos=n;
while(Q)
{
Q=(st+dr)>>1;
S=query(Q);
if(S>suma)
{
if(dr>Q) dr=Q;
Q--;
}
else if(S==suma)
{
if(pos>Q) pos=Q;
dr=Q, Q--;
}
else {
if(st<Q) st=Q;
Q++;
}
if(Q<=st || Q>=dr) break;
}
if(pos==n+1) return -1;
return pos;
}
int main()
{
memset(arbore,0,sizeof(arbore));
fscanf(f,"%d %d",&n,&m);
for(i=1;i<=n;i++)
{
fscanf(f,"%d",&x);
update(i,x);
}
//for(i=1;i<=n;i++) fprintf(g,"%d ",arbore[i]);
for(i=1;i<=m;i++)
{
fscanf(f,"%d",&k);
if(k==0){
fscanf(f,"%d %d",&a,&b);
update(a,b);
}
else
if(k==1){
fscanf(f,"%d %d",&a,&b);
fprintf(g,"%d\n",query(b)-query(a-1));
}
else {
fscanf(f,"%d",&a);
fprintf(g,"%d\n",cautare(a));
}
}
fclose(f);
fclose(g);
return 0;
}