#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <functional>
#include <bitset>
#include <set>
using namespace std;
int aib[100005];
int n, m;
void update(int idx, int val) {
for (; idx <= n; idx += idx & (-idx))
aib[idx] += val;
}
int query(int idx) {
int res = 0;
for (; idx > 0; idx -= idx & (-idx))
res += aib[idx];
return res;
}
int search(int val) {
int i, step;
for (step = 1; step < n; step <<= 1);
for (i = 0; step; step >>= 1) {
if (i + step <= n && val >= aib[i + step]) {
i += step;
val -= aib[i];
if (val == 0) return i;
}
}
return -1;
}
int main() {
ios::sync_with_stdio(false);
string filename = "aib";
ifstream fin(filename + ".in");
ofstream fout(filename + ".out");
fin >> n >> m;
for (int i = 1; i <= n; ++i) {
int elem;
fin >> elem;
update(i, elem);
}
while (m--) {
int typeOp, a, b;
fin >> typeOp >> a;
if (typeOp != 2) fin >> b;
if (typeOp == 0) update(a, b);
else if (typeOp == 1) fout << query(b) - query(a - 1) << "\n";
else fout << search(a) << "\n";
}
//system("pause");
return 0;
}