#include <iostream>
using namespace std;
//Дерево отрезков.
struct segment_tree{
long *tree;
//Конструктор.
segment_tree(int length){
tree = new long[4*length+1];
}
//Построение дерева отрезков по массиву a.
void build(int *a, int v, int tree_l, int tree_r){
if(tree_l == tree_r) tree[v] = a[tree_l];
else{
int tree_m = (tree_l + tree_r)/2;
build(a, v*2, tree_l, tree_m);
build(a, v*2+1, tree_m+1, tree_r);
tree[v] = tree[v*2] + tree[v*2+1];
}
}
//Присваивание человечку на позиции pos веса new_val.
void update(int v, int tree_l, int tree_r, int pos, int new_val){
if(tree_l == tree_r) tree[v] = new_val;
else{
int tree_m = (tree_l + tree_r)/2;
if(pos <= tree_m){
update(v*2, tree_l, tree_m, pos, new_val);
}
else{
update(v*2+1, tree_m+1, tree_r, pos, new_val);
}
tree[v] = tree[v*2] + tree[v*2+1];
}
}
//Нахождение количества поместившихся человечков.
int find_numb_of_p(int v, int tree_l, int tree_r, int max_w){
if(tree_l == tree_r) return tree[v] <= max_w;
int tree_m = (tree_l + tree_r)/2;
if(tree[v*2] > max_w)
return find_numb_of_p(v*2, tree_l, tree_m, max_w);
else
return tree_m - tree_l + 1 + find_numb_of_p(v*2+1, tree_m+1, tree_r, max_w-tree[v*2]);
}
};
int main() {
int n, m, *weights;
cin >> n;
//Заполнение массива весов человечков.
weights = new int[n+1];
for(int i = 1; i <= n; ++i){
cin >> weights[i];
}
//Построение дерева отрезков.
segment_tree tr(n);
tr.build(weights, 1, 1, n);
//Обработка запросов.
cin >> m;
int type, x, y, v;
for(int i = 0; i < m; ++i){
cin >> type;
if(type == 2){
cin >> x >> y;
tr.update(1, 1, n, x, y);
}
else{
cin >> v;
cout << tr.find_numb_of_p(1, 1, n, v) << '\n';
}
}
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKLy/QlNC10YDQtdCy0L4g0L7RgtGA0LXQt9C60L7Qsi4Kc3RydWN0IHNlZ21lbnRfdHJlZXsKCWxvbmcg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