#include <bits/stdc++.h>
using namespace std;
ifstream fin("aib.in");
ofstream fout("aib.out");
#define lsb(i) (i & (-i))
const int NMAX = 1e5 + 1, LOG = 16;
int n, q, arr[NMAX];
class FenwickTree
{
private:
int tree[NMAX];
public:
void update(int x, int val)
{
for(int i = x; i <= n; i += lsb(i))
tree[i] += val;
}
int query(int x)
{
int sum = 0;
for(int i = x; i > 0; i -= lsb(i))
sum += tree[i];
return sum;
}
int caut_bin(int x)
{
int ans = 0, sum = 0;
for(int pas = (1 << LOG); pas > 0; pas >>= 1)
{
if(ans + pas <= n && sum + tree[ans + pas] < x)
{
sum += tree[ans + pas];
ans += pas;
}
}
return (query(ans + 1) == x ? ans + 1 : -1);
}
};
FenwickTree aib;
int main()
{
fin >> n >> q;
for(int i = 1; i <= n; i++)
{
fin >> arr[i];
aib.update(i, arr[i]);
}
while(q--)
{
int tip; fin >> tip;
if(tip == 0)
{
int x, val;
fin >> x >> val;
aib.update(x, val);
}
else if(tip == 1)
{
int st, dr;
fin >> st >> dr;
fout << aib.query(dr) - aib.query(st - 1) << "\n";
}
else
{
int sum;
fin >> sum;
fout << aib.caut_bin(sum) << "\n";
}
}
fin.close();
fout.close();
return 0;
}