import java.util.*;
import java.io.*;
{
int cur, res;
{
cur = read();
res = 0;
while(cur!=32 && cur!=-1 && cur != '\n'){
res*=10;
res += (int)(cur-'0');
cur = read();
}
return res;
}
}
//Дерево отрезков.
class SegmentTree
{
static long []tree;
//Конструктор.
SegmentTree(int length){tree = new long[4*length+1];}
void build
(int v,
int treeL,
int treeR, FastIntReader in
) throws IOException {
if(treeL == treeR) tree[v] = in.getNextInt();
else{
int treeM = (treeL + treeR)/2;
build(v*2, treeL, treeM, in);
build(v*2+1, treeM+1, treeR, in);
tree[v] = tree[v*2] + tree[v*2+1];
}
}
//Присваивание человечку на позиции pos веса newVal.
void update(int v, int treeL, int treeR, int pos, int newVal)
{
if(treeL == treeR) tree[v] = newVal;
else{
int treeM = (treeL + treeR)/2;
if(pos <= treeM){
update(v*2, treeL, treeM, pos, newVal);
}
else{
update(v*2+1, treeM+1, treeR, pos, newVal);
}
tree[v] = tree[v*2] + tree[v*2+1];
}
}
//Нахождение количества поместившихся человечков.
int findNumberOfPeople(int v, int treeL, int treeR, long max_w)
{
if(treeL == treeR){
if(tree[v] <= max_w) return 1;
else return 0;
}
int treeM = (treeL + treeR)/2;
if(tree[v*2] > max_w)
return findNumberOfPeople(v*2, treeL, treeM, max_w);
else
return treeM - treeL + 1 + findNumberOfPeople(v*2+1, treeM+1, treeR, max_w-tree[v*2]);
}
}
class Main
{
{
FastIntReader in
= new FastIntReader
(System.
in); //Построение дерева отрезков.
int n, m;
n = in.getNextInt();
SegmentTree tr = new SegmentTree(n);
tr.build(1, 1, n, in);
//Обработка запросов.
m = in.getNextInt();
int type, x, y, v;
for(int i = 0; i < m; ++i){
type = in.getNextInt();
if(type == 2){
x = in.getNextInt();
y = in.getNextInt();
tr.update(1, 1, n, x, y);
}
else{
v = in.getNextInt();
out.print(tr.findNumberOfPeople(1, 1, n, v));
out.print('\n');
}
}
out.flush();
}
}
aW1wb3J0IGphdmEudXRpbC4qOwppbXBvcnQgamF2YS5pby4qOwoKY2xhc3MgRmF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