#include <stdio.h>
int t[210000],m,n,i,x,y,z,sol;
FILE * in,* out;
int next_int(FILE * in)
{
char x,y;
int z=0;;
x=1;
while (x<48 || x> 57)
y=fread(&x,1,1,in);
while (x>=48 && x<=57)
z=(z<<1)+(z<<3)+x-48,y=fread(&x,1,1,in);
return z;
}
void build_tree(int st,int dr,int v)
{
if (st==dr)
t[v]=next_int(in);
else
{
int m=(st+dr)>>1;
int k=v<<1;
build_tree(st,m,k);
build_tree(m+1,dr,k+1);
t[v]=t[k]+t[k+1];
}
}
void update(int st,int dr,int v)
{
if (st==dr)
t[v]+=z; else
{
int m=(st+dr)>>1;
if (y<=m)
update(st,m,2*v); else
update(m+1,dr,2*v+1);
t[v]=t[2*v]+t[2*v+1];
}
}
void q1(int st,int dr,int v,int l,int r)
{
if (st>=l && dr<=r)
sol+=t[v];
else
{
int m=(st+dr)>>1;
if (r<=m)
q1(st,m,2*v,l,r); else
if (l>m)
q1(m+1,dr,2*v+1,l,r); else
{
q1(st,m,2*v,l,m);
q1(m+1,dr,2*v+1,m+1,r);
}
}
}
void q2(int st,int dr,int v)
{
if (st==dr)
{
if (y==t[v])
fprintf(out,"%d\n",st); else
fprintf(out,"-1\n");
} else
{
int m=(st+dr)>>1;
if (y>t[2*v])
{
y-=t[2*v];
q2(m+1,dr,2*v+1);
} else
q2(st,m,2*v);
}
}
int main(int argc, char const *argv[])
{
in = fopen("aib.in","r");
out = fopen("aib.out","w");
n=next_int(in);
m=next_int(in);
build_tree(1,n,1);
while (m--)
{
x=next_int(in);
y=next_int(in);
if (x!=2)
z=next_int(in);
if (x==0)
update(1,n,1); else
if (x==1)
{
sol=0;
q1(1,n,1,y,z);
fprintf(out,"%d\n",sol);
} else
q2(1,n,1);
}
fclose(in);
fclose(out);
return 0;
}