#include <fstream>
using namespace std;
ifstream cin("aib.in");
ofstream cout("aib.out");
const int N = 100100;
int aib[N], n;
void update(int idx, int val) {
for (; idx <= n; idx += idx & -idx)
aib[idx] += val;
}
int query(int idx) {
int sum = 0;
for (; idx > 0; idx -= idx & -idx)
sum += aib[idx];
return sum;
}
int find(int val) {
int idx = 0, mask = 1;
while (mask < n) mask <<= 1;
for (; mask; mask >>= 1) {
int nidx = idx + mask;
if (nidx <= n && aib[nidx] <= val) {
val -= aib[nidx];
idx = nidx;
}
}
return idx + 1;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int m;
cin >> n >> m;
for (int i = 1; i <= n; ++i) {
int x;
cin >> x;
update(i, x);
}
while (m--) {
int type;
cin >> type;
if (type == 0) {
int a, b;
cin >> a >> b;
update(a, b);
} else if (type == 1) {
int a, b;
cin >> a >> b;
cout << query(b) - query(a - 1) << '\n';
} else {
int a;
cin >> a;
cout << find(a) << '\n';
}
}
return 0;
}