#include <bits/stdc++.h>
#define NMAX 100005
using namespace std;
ifstream fin("aib.in");
ofstream fout("aib.out");
int n, m, v[2 * NMAX];
void read();
void solve();
int lsb(int pos) {
return pos & -pos;
}
void update(int pos, int val) {
while (pos <= n) {
v[pos] += val;
pos += lsb(pos);
}
}
int query(int pos) {
int s = 0;
while (pos > 0) {
s += v[pos];
pos -= lsb(pos);
}
return s;
}
int q3(int a) {
int p = 0, k = 0;
while ((1 << p) < n)
p++;
int crtSum = 0;
while (p >= 0) {
if (k + (1 << p) <= n) {
if (crtSum + v[k + (1 << p)] == a)
return k + (1 << p);
if (crtSum + v[k + (1 << p)] < a) {
k += (1 << p);
crtSum += v[k];
}
}
p--;
}
return -1;
}
int main() {
read();
solve();
return 0;
}
void read() {
int x;
fin >> n >> m;
for (int i = 1; i <= n; i++) {
fin >> x;
update(i, x);
}
}
void solve() {
int op, a, b;
for (int q = 1; q <= m; ++q) {
fin >> op >> a;
if (op != 2)
fin >> b;
if (op == 0)
update(a, b);
else if (op == 1)
fout << query(b) - query(a - 1) << '\n';
else fout << q3(a) << '\n';
}
}