#include<bits/stdc++.h>
#define For(i,x,y) for (register int i=(x);i<=(y);i++)
#define FOR(i,x,y) for (register int i=(x);i<(y);i++)
#define Dow(i,x,y) for (register int i=(x);i>=(y);i--)
#define Debug(v) for (auto i:v) cout<<i<<" ";puts("")
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define ep emplace_back
#define siz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define fil(a,b) memset((a),(b),sizeof(a))
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pa;
typedef pair<ll,ll> PA;
typedef vector<int> poly;
inline ll read(){
	ll x=0,f=1;char c=getchar();
	while ((c<'0'||c>'9')&&(c!='-')) c=getchar();
	if (c=='-') f=-1,c=getchar();
	while (c>='0'&&c<='9') x=x*10+c-'0',c=getchar();
	return x*f;
}

const int N = 1e5+10, M = 1010;
int n,q,B,a[N],id[N],cnt[M];

int b[M],tag[M<<2];
pa mn[M<<2];
inline void Build(int u,int l,int r){
	tag[u]=0;
	if (l==r) return mn[u]=mp(b[l],l),void(0);
	int mid=l+r>>1;
	Build(u<<1,l,mid),Build(u<<1^1,mid+1,r);
	mn[u]=min(mn[u<<1],mn[u<<1^1]);
}
inline void update(int u,int l,int r,int ql){
	if (l>ql) return tag[u]--,mn[u].fi--,void(0);
	if (l==r) return mn[u]=mp(1e9,l),void(0);
	int mid=l+r>>1;
	update(u<<1^1,mid+1,r,ql);
	if (ql<=mid) update(u<<1,l,mid,ql);
	mn[u]=min(mn[u<<1],mn[u<<1^1]),mn[u].fi+=tag[u];
}
int v[M][M];
inline void ReBuild(int id){
	int l=(id-1)*B+1,r=min(id*B,n),cnt=0;
	For(i,l,r) b[++cnt]=a[i];
	Build(1,1,cnt);
	For(i,1,cnt){
		int tmp=mn[1].fi;
		v[id][i]=max(tmp,v[id][i-1]),update(1,1,cnt,mn[1].se);
	}
}

inline int Query(int x){
	int y=a[x];
	For(i,x+1,min(id[x]*B,n)) y+=(y>=a[i]);
	For(i,id[x]+1,id[n]){
		int tmp=upper_bound(v[i]+1,v[i]+cnt[i]+1,y)-v[i]-1;
		y+=tmp;
	}
	return n-y;
}

int main(){
	n=read(),B=150;
	For(i,1,n) a[i]=read(),id[i]=(i-1)/B+1,cnt[id[i]]++;
	For(i,1,id[n]) ReBuild(i);
	q=read();
	while (q--){
		int op=read(),x=read();
		if (op==1){
			int y=read();
			a[x]=y,ReBuild(id[x]);
		} else {
			printf("%d\n",Query(x));
		}
	}
}