#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#define ll long long
#define ld long double
#define ull unsigned long long
#define ff first
#define ss second
#define pii pair<int,int>
#define pll pair<long long, long long>
#define vi vector<int>
#define vl vector<long long>
#define pb push_back
#define rep(i, b) for(int i = 0; i < (b); ++i)
#define rep2(i,a,b) for(int i = a; i <= (b); ++i)
#define rep3(i,a,b,c) for(int i = a; i <= (b); i+=c)
#define count_bits(x) __builtin_popcountll((x))
#define all(x) (x).begin(),(x).end()
#define siz(x) (int)(x).size()
#define forall(it,x) for(auto& it:(x))
using namespace __gnu_pbds;
using namespace std;
typedef tree<int, null_type, less<int>, rb_tree_tag,tree_order_statistics_node_update> ordered_set;
//mt19937 mt;void random_start(){mt.seed(chrono::time_point_cast<chrono::milliseconds>(chrono::high_resolution_clock::now()).time_since_epoch().count());}
//ll los(ll a, ll b) {return a + (mt() % (b-a+1));}
const int INF = 1e9+50;
const ll INF_L = 1e18+40;
const ll MOD = 1e9+7;
struct elm
{
ll sum,bor;
int cnt;
};
struct node
{
vector<elm> pref;
vector<elm> suf;
void set_num(ll x)
{
pref = {{0,x,0},{x,(ll)1e18,1}};
suf = {{0,x,0},{x,(ll)1e18,1}};
}
};
void calc_pref(node a, node b, node& ans)
{
ans.pref = a.pref;
ans.pref.pop_back();
int cur_suf = 0;
int cur_pref = 0;
rep(i,siz(a.suf))
{
while(a.suf[i].sum+b.pref[cur_pref].sum >= b.pref[cur_pref].bor) cur_pref++;
if(i != siz(a.suf) && a.suf[i].sum+b.pref[cur_pref].sum >= a.suf[i].bor) a.suf[i+1].cnt += a.suf[i].cnt;
}
rep(i,siz(b.pref))
{
if(i==cur_pref) ans.pref.pb({a.pref.back().sum+b.pref[i].sum,b.pref[i].bor,a.suf.back().cnt});
while(b.pref[i].sum+a.suf[cur_suf].sum >= a.suf[cur_suf].bor) cur_suf++;
if(i != siz(b.pref)-1 && a.suf[cur_suf].sum+b.pref[i].sum >= b.pref[i].bor) b.pref[i+1].cnt += b.pref[i].cnt;
else
{
if(cur_suf == siz(a.suf)-1)
{
if(i != cur_pref) ans.pref.pb({a.suf.back().sum+b.pref[i].sum,b.pref[i].bor,b.pref[i].cnt});
else ans.pref.back().cnt += b.pref[i].cnt;
}
}
}
}
void merge(node a, node b, node& ans)
{
if(siz(a.pref) == 0)
{
ans = b;
return;
}
if(siz(b.pref) == 0)
{
ans = a;
return;
}
ans.pref = {};
ans.suf = {};
calc_pref(a,b,ans);
swap(a,b);
swap(ans.pref,ans.suf);
swap(a.pref,a.suf);
swap(b.pref,b.suf);
calc_pref(a,b,ans);
swap(ans.pref,ans.suf);
}
const int tree_siz = 1024*256-1;
node tree_[tree_siz+1];
node pom;
node get_node(int akt, int p1, int p2, int s1, int s2)
{
if(p2 < s1 || p1 > s2) return pom;
if(p1 >= s1 && p2 <= s2) return tree_[akt];
node ans;
merge(get_node(akt*2,p1,(p1+p2)/2,s1,s2),get_node(akt*2+1,(p1+p2)/2+1,p2,s1,s2),ans);
return ans;
}
void upd(int v)
{
merge(tree_[v*2],tree_[v*2+1],tree_[v]);
if(v != 1) upd(v/2);
}
void change(int v, int p)
{
tree_[tree_siz/2+1+v].set_num(p);
upd((tree_siz/2+1+v)/2);
}
int main()
{
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
//random_start();
int n;
cin >> n;
rep2(i,1,n)
{
int x;
cin >> x;
change(i,x);
}
int q;
cin >> q;
rep(qq,q)
{
int t;
cin >> t;
if(t == 1)
{
int x,y;
cin >> x >> y;
change(x,y);
}
else
{
int l,r;
cin >> l >> r;
node ans = get_node(1,0,tree_siz/2,l,r);
cout << ans.suf.back().cnt << "\n";
}
}
}