#include <iostream>
using namespace std;
struct tree {
long * tr;
tree(int n) {
tr = new long[4 * n + 1];
}
void build(int * arr, int v, int l, int r) {
if (l == r) tr[v] = arr[l];
else {
int mid = (l + r) / 2;
build(arr, v * 2, l, mid);
build(arr, v * 2 + 1, mid + 1, r);
tr[v] = tr[v * 2] + tr[v * 2 + 1];
}
}
void update(int v, int l, int r, int pos, int val) {
if (l == r) tr[v] = val;
else {
int mid = (l + r) / 2;
if (pos <= mid) update(v * 2, l, mid, pos, val);
else update(v * 2 + 1, mid + 1, r, pos, val);
tr[v] = tr[v * 2] + tr[v * 2 + 1];
}
}
int find(int v, int l, int r, int max) {
if (l == r)
return (tr[v] <= max);
int mid = (l + r) / 2;
if (tr[v * 2] > max)
return find(v * 2, l, mid, max);
else
return mid - l + 1 + find(v * 2 + 1, mid + 1, r, max - tr[v * 2]);
}
};
int main() {
int n, m, * arr;
cin >> n;
arr = new int[n + 1];
for (int i = 1; i <= n; ++i) cin >> arr[i];
tree tr(n);
tr.build(arr, 1, 1, n);
cin >> m;
int com, x, y, v;
for (int i = 0; i < m; ++i) {
cin >> com;
switch (com) {
case 1:
{
cin >> v;
cout << tr.find(1, 1, n, v) << '\n';
break;
}
case 2:
{
cin >> x >> y;
tr.update(1, 1, n, x, y);
break;
}
}
}
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKc3RydWN0IHRyZWUgewogICAgbG9uZyAqIHRyOwogICAgdHJlZShpbnQgbikgewogICAgICAgIHRyID0gbmV3IGxvbmdbNCAqIG4gKyAxXTsKICAgIH0KICAgIHZvaWQgYnVpbGQoaW50ICogYXJyLCBpbnQgdiwgaW50IGwsIGludCByKSB7CiAgICAgICAgaWYgKGwgPT0gcikgdHJbdl0gPSBhcnJbbF07CiAgICAgICAgZWxzZSB7CiAgICAgICAgICAgIGludCBtaWQgPSAobCArIHIpIC8gMjsKICAgICAgICAgICAgYnVpbGQoYXJyLCB2ICogMiwgbCwgbWlkKTsKICAgICAgICAgICAgYnVpbGQoYXJyLCB2ICogMiArIDEsIG1pZCArIDEsIHIpOwogICAgICAgICAgICB0clt2XSA9IHRyW3YgKiAyXSArIHRyW3YgKiAyICsgMV07CiAgICAgICAgfQogICAgfQogICAgdm9pZCB1cGRhdGUoaW50IHYsIGludCBsLCBpbnQgciwgaW50IHBvcywgaW50IHZhbCkgewogICAgICAgIGlmIChsID09IHIpIHRyW3ZdID0gdmFsOwogICAgICAgIGVsc2UgewogICAgICAgICAgICBpbnQgbWlkID0gKGwgKyByKSAvIDI7CiAgICAgICAgICAgIGlmIChwb3MgPD0gbWlkKSB1cGRhdGUodiAqIDIsIGwsIG1pZCwgcG9zLCB2YWwpOwogICAgICAgICAgICBlbHNlIHVwZGF0ZSh2ICogMiArIDEsIG1pZCArIDEsIHIsIHBvcywgdmFsKTsKICAgICAgICAgICAgdHJbdl0gPSB0clt2ICogMl0gKyB0clt2ICogMiArIDFdOwogICAgICAgIH0KICAgIH0KICAgIGludCBmaW5kKGludCB2LCBpbnQgbCwgaW50IHIsIGludCBtYXgpIHsKICAgICAgICBpZiAobCA9PSByKQogICAgICAgICAgICByZXR1cm4gKHRyW3ZdIDw9IG1heCk7CiAgICAgICAgaW50IG1pZCA9IChsICsgcikgLyAyOwogICAgICAgIGlmICh0clt2ICogMl0gPiBtYXgpCiAgICAgICAgICAgIHJldHVybiBmaW5kKHYgKiAyLCBsLCBtaWQsIG1heCk7CiAgICAgICAgZWxzZQogICAgICAgICAgICByZXR1cm4gbWlkIC0gbCArIDEgKyBmaW5kKHYgKiAyICsgMSwgbWlkICsgMSwgciwgbWF4IC0gdHJbdiAqIDJdKTsKICAgIH0KfTsKCmludCBtYWluKCkgewogICAgaW50IG4sIG0sICogYXJyOwogICAgY2luID4+IG47CiAgICBhcnIgPSBuZXcgaW50W24gKyAxXTsKICAgIGZvciAoaW50IGkgPSAxOyBpIDw9IG47ICsraSkgY2luID4+IGFycltpXTsKICAgIHRyZWUgdHIobik7CiAgICB0ci5idWlsZChhcnIsIDEsIDEsIG4pOwogICAgY2luID4+IG07CiAgICBpbnQgY29tLCB4LCB5LCB2OwogICAgZm9yIChpbnQgaSA9IDA7IGkgPCBtOyArK2kpIHsKICAgICAgICBjaW4gPj4gY29tOwogICAgICAgIHN3aXRjaCAoY29tKSB7CiAgICAgICAgY2FzZSAxOgogICAgICAgICAgICB7CiAgICAgICAgICAgICAgICBjaW4gPj4gdjsKICAgICAgICAgICAgICAgIGNvdXQgPDwgdHIuZmluZCgxLCAxLCBuLCB2KSA8PCAnXG4nOwogICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIH0KICAgICAgICBjYXNlIDI6CiAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgIGNpbiA+PiB4ID4+IHk7CiAgICAgICAgICAgICAgICB0ci51cGRhdGUoMSwgMSwgbiwgeCwgeSk7CiAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgfQogICAgICAgIH0KICAgIH0KICAgIHJldHVybiAwOwp9