#include <iostream>
#include <fstream>
using namespace std;
int v[100001], aib[100001];
int n;
void update(int i, int b){
int a=v[i], l;
l=i;
while(l<=n){
aib[l]+=b-a;
l+=(l&(-l));
}
}
int rasp(int i){
int l=i, s=0;
while(l>0){
s+=aib[l];
l-=(l&(-l));
}
return s;
}
int main()
{
ifstream fin("aib.in");
ofstream fout("aib.out");
int q, i, t, a, b, st, dr, mij, c;
fin>>n>>q;
for(i=1;i<=n;i++){
fin>>c;
update(i,c);
v[i]=c;
//cout<<aib[i]<<' ';
}
for(i=0;i<q;i++){
fin>>t;
if(t==0){
fin>>a>>b;
update(a,v[a]+b);
}
else if(t==1){
fin>>a>>b;
fout<<rasp(b)-rasp(a-1)<<'\n';
}
else{
fin>>a;
st=0;
dr=n+1;
while(st+1<dr){
mij=(st+dr)/2;
if(rasp(mij)<a){
st=mij;
}
else{
dr=mij;
}
}
if(rasp(dr)==a){
fout<<dr<<'\n';
}
else{
fout<<"-1\n";
}
}
}
return 0;
}