#include <fstream>
#define NMAX 100000
#define LSB(x) x^(x&(x-1))
using namespace std;
ifstream fi("aib.in");
ofstream fo("aib.out");
int n, m, nr=1, putere;
int X[NMAX+5], AIB[NMAX+5];
void update(int pos, int val)
{
while(pos<=n)
{
AIB[pos]+=val;
pos+=LSB(pos);
}
}
void build(void)
{
for(int i=1; i<=n; i++)
update(i, X[i]);
}
int suma(int pos)
{
int sum=0;
while(pos)
{
sum+=AIB[pos];
pos-=LSB(pos);
}
return sum;
}
int posmin(int val)
{
int putere, lo=1, hi, s, i;
hi=putere=nr;
s=AIB[nr];
for(i=0; putere; putere/=2)
if(i+putere<=n && AIB[i+putere]<=val)
{
i+=putere;
val-=AIB[i];
if(val==0)
return i;
}
return -1;
}
int main()
{
fi>>n>>m;
for(int i=1; i<=n; i++)
fi>>X[i];
build();
while(nr*2<=n)
nr*=2;
while(m--)
{
int q, a, b;
fi>>q;
if(q==0)
{
fi>>a>>b;
update(a, b);
}
else if(q==1)
{
fi>>a>>b;
fo<<suma(b)-suma(a-1)<<"\n";
}
else
{
fi>>a;
fo<<posmin(a)<<"\n";
}
}
fi.close();
fo.close();
return 0;
}