#include <fstream>
#define lsb(x) -x&x
#define FOR(i, start, final) for (int i=start; i<=final; ++i)
using namespace std;
ifstream f("aib.in");
ofstream g("aib.out");
int N, M, tip, a, b, aib[100005], x;
void upd(int poz, int val)
{
while (poz<=N)
aib[poz]+=val, poz+=lsb(poz);
}
int query(int poz)
{
int sum=0;
while (poz)
sum+=aib[poz], poz-=lsb(poz);
return sum;
}
int main()
{
f>>N>>M;
FOR(i,1,N) f>>x, upd(i, x);
while (M--)
{
f>>tip>>a;
if (tip<2)
{
f>>b;
if (tip==0) upd(a, b);
else g<<query(b)-query(a-1)<<'\n';
continue;
}
else
{
int poz=0, lg=(1<<30), sol=-1;
for (; lg; lg>>=1)
if (poz+lg<=N && aib[poz+lg]<=a)
{
a-=aib[poz+lg]; poz+=lg;
if (a==0) { sol=poz; break; }
}
g<<sol<<'\n';
}
}
return 0;
}