#include <fstream>
using namespace std;
ifstream cin("aib.in");
ofstream cout("aib.out");
int aib[400010],a,b,n,m,op;
int sum(int poz)
{
int s(0);
while (poz>0)
s+=aib[poz], poz-=poz & -poz;
return s;
}
void update(int poz, int val)
{
while (poz<=n)
aib[poz]+=val, poz+=poz & -poz;
}
int main()
{
cin>>n>>m;
int x;
for (int i=1;i<=n;i++) cin>>x, update(i,x);
while (m--)
{
cin>>op;
if (op==0)
{
cin>>a>>b;
update(a,b);
}
else if (op==1)
{
cin>>a>>b;
cout<<sum(b)-sum(a-1)<<"\n";
} else
{
cin>>a;
int st=1,dr=n,mij;
while (st<=dr)
{
mij=(st+dr)/2;
int s=sum(mij);
if (s==a)
break;
if (s>a)
dr=mij-1;
else st=mij+1;
}
cout<<mij<<"\n";
}
}
return 0;
}