Problem: You were playing with permutation p of length n, but you lost it in Blair, Alabama!

Luckily, you remember some information about the permutation. More specifically, you remember an array b of length n, where b_i is the number of indices j such that j < i and p_j > p_i.

You have the array b, and you want to find the permutation p. However, your memory isn't perfect, and you constantly change the values of b as you learn more. For the next q seconds, one of the following things happen:

  1. 1 i x — you realize that b_i is equal to x; 
  2. 2 i — you need to find the value of p_i. If there's more than one answer, print any. It can be proven that there's always at least one possible answer under the constraints of the problem. 



Answer the queries, so you can remember the array!

Input

The first line contains a single integer n (1 ≤ n ≤ 10^5) — the size of permutation.

The second line contains n integers b_1, b_2 …, b_n (0 ≤ b_i < i) — your initial memory of the array b.

The third line contains a single integer q (1 ≤ q ≤ 10^5) — the number of queries.

The next q lines contain the queries, each with one of the following formats: 

  * 1 i x (0 ≤ x < i ≤ n), representing a query of type 1. 
  * 2 i (1 ≤ i ≤ n), representing a query of type 2. 



It is guaranteed that there's at least one query of type 2.

Output

For each query of type 2, print one integer — the answer to the query.

Examples

Input


3
0 0 0
7
2 1
2 2
2 3
1 2 1
2 1
2 2
2 3


Output


1
2
3
2
1
3


Input


5
0 1 2 3 4
15
2 1
2 2
1 2 1
2 2
2 3
2 5
1 3 0
1 4 0
2 3
2 4
2 5
1 4 1
2 3
2 4
2 5


Output


5
4
4
3
1
4
5
1
5
4
1

Note

For the first sample, there's initially only one possible permutation that satisfies the constraints: [1, 2, 3], as it must have 0 inversions.

After the query of type 1, the array b is [0, 1, 0]. The only permutation p that produces this array is [2, 1, 3]. With this permutation, b_2 is equal to 1 as p_1 > p_2.

Solution (in CPP):

Solution:
/*
XqQRREXJ7ii:..::::iiiiiirirrv7vvvvsuIXDQBBBDPJ7i:...::r2vrrr7rrr7rvJLuqPXdd22Yrii:.:.  .::......... ..........:.....:...:.:.:...:...:...:.:.:...:.:.:.
r:irrLuIIqX52u7i::.......::::::::i:i:::rrvsSKZEgEP2uri.i::.:...::..i::.::r77vUJ1r: .                                                 .   .     .   .
i:i:i:i:rrvLSPdZQDEqKjY7i:::::::i:i:iii:iiiiir7YIbMMRgSL7irriijPDKqqKUI15XZPXSEMBQD5uIJ::.    ... . ....................................:.......:.:...
:.:::::i:::::iiirvLjIPDgEDPXUu7r::::.::::i:iiiii:::r7UdPKggMDRQBBBBBQBBBBBBBBBBBBBQBBBBM57::       ...................................................
vii::...::::::::::::::iirvj2PdZdDddSuvri::..:::.:r1dRQBBBBBBBBBBBBBQBQBBBQBQBQBBBQBBBBBBBBQgXr.         ..............................................
gDDZPKuv7r::::.:.::::::::i:::iir7sjISbPEK2Yvr7YPMBQBBBQBBBBBBBBBBBBBQBBBBBQBQBQQQQRBQBQBBBBBBBdvi:         ...........................................
::vLuUqbZEgEb5jvvii:::::::::::::::::iivs5PQQBBBQBBBQQQBQQQBQBQBQBBBQBQBQBBBQBQQQQQBQBBBQBQQQBBBBBMXYv7i.    . ........................................
:::::::::r7YY5qZgQDPI5uvrr::.:::::.::7sIbQBBBBBBQBQBQBQBQBBBQBBBBBQBQBQBQBQQQQQBQBQQBBQBQBQQRBQBBBBBBBgIr:.    .......................................
:.::::::::::::i:ii7vu2XPggMPP51vr::ivJSEQQBQBQBQBQBQBBBQBQBQBQBQBQBBBBBQBBBQQQBQBQBQBBBQBQBQBQBQBQBQBQBBBggX7.  .....................................
7i::.....::::::::::::::iir7YuSXqXXqdZMQBBBQBQBQQQBBBBBBBQBQBQBBBQBQBQBBBQBQBQBQBQBQBQBQBQBQBBBQBQBQQQBQBQBRBBPi. .....................................
ZqgDESIJvrr::.:::.::::::::::::::ivdRBBBQBBBQBQQQBQBQBQBQBQBQBQBQBQBQBQBQBQBQBQBQBQBQBQBQBQBBBQBQBQQQQQQQQRMPKPP7. ...................................
i:i7vU5KSbZZPdSjv7i:.:...:.:::.i7PQBBBQBBBBBQBQBBBQBQBQBQBQBQBBBQBQBQBQBQQQQRQQBQQQQQQQQQBQBBBQBQQQQRQRQRQQBgggI:.....................................
i.::::::::rrvs12PPPbgdXJsri:::vKRBBBBQBQBBBBBQBBBQBQBQBQBQBQBQBQQQQQQRBQBQQRQMQQBQQQQQBQBQBQBQBQBQQRQRBQBQQQBQQdv.....................................
..:::::::::::::::ii77YUqqdbZXEQBQBQBBBQBQBBBBBBBQBQQQBQBQBQBQBQBRQQQMQQBQQQBQQRBQQQQQQMQQQQBQQQBQQRQMQRQMQRQRQBQdr ...................................
si7i::..:.:.::::::::::i:i::i5QBQBQBQBQBQBQBQBBBQBQBQQQBQQQBQQQQQQQQQQQBQBBBBBQBQQQQMMgRgQQBQQQBQQQQMRgQMQRQRQRBQQPi .................................
qPZZddS2jvri::.....::::::::7ZBBBQBQBQBQBQBQBBBQBQBQBBBBBQQRQQQQQQQRQRQRQgMZDDgZgZgEZEZEggMRBQBRQQQMQMQRQMQRQgRRBMqv  .................................
:.ri77j5PqEddKP51v7ii::...:1BBBQBQBBBQBBBQBQQQQQBQBQQQBQQRQMBQBRQQQMRggPK555X5SXPPKSPbZZggRMQQQRQQQRQMQMQMQgQMQQQbu. ................................
:.:i:i:::::rrvs22SPEdbqbIvrdBBQQBBBBQBBBQBQBQBQBQBQBQQQBQQgQRQZdMgDgdbSSUIU2u1JUjUssuXPPPZZZKqgRDMRQQQQQRQRQgQMQQBg7 ................................
:.::::::::i:::::::iir7vs11PQBBBQQQBQBQBQBQBQBBBBBQBQQQQMgZggQEX5ZbEdPSSI5IUJuYJj1j1j5XPXqqqI2uPZDEgDRRQQQMQgQgQRQBBd: ...............................
17rr::.:...::::::::::::::isRQBQBQQQBQBQBQBQBQBQBQQQQQQQQdddZdES5IPqqI5U1JusJYYvJ1I5X5SIIu1LvvYY2IqqPbDDggQRMgMgQQQBBv  ...............................
K2DDEPPXSJYvr::.:.:.::::i2QBBQBQBQBBBBBQBQBQBQQQBQRgQMQgEqXSKKXJsvsYJsJ77r77vvLvvLJLJsjv77777777YYU2qPEEZDRgRgMgQQQBR: ..............................
:.:ii7LjuXPDPbbP51Jsri::.YQBBBQBBBQBQBQBQBQBBBQBQRgRMgPPKqSIUIUuLJsjYYv77v7v7v7v777777irirr77777r7rYsU5ddDDRMQRRgRQBBI. ..............................
i.i:::::::::ii7vj2SSbERbXqBBBQBQBBBQBQBQBQBBBQBRQRQRQdqXKSKI2uusJLYvv7vrrirrrr77777r7rrrrirr777r7r77Ys15bbEERgRgRMQRBgi .............................
...:::::::::::::::::iri7vLbBQBQBQBQBQBQBQBQBBBQQQQRQgdXX55I52UsJsY7777r7rririrr7r7r7rrv7rrrrrrrrrrr77vL1IqqbEZbRgQMQQBY...............................
Uvsri:::....:.::::::i:::irZQBQBQBQBQBQBQBQBQBQQQQRQQRPPPq555X1uLJLv77r7rrrrr7r7rrrrr7rvrrirrrrrrrr77v7sLjJU5EZEDQQBQQB5..............................
U1KEdDZP55svrri:::.:.::::UgBBBQQQBBBQBQBQBQBRQQBQBQRDgPPKK5SS2uuss7v77r777r7r7r7r7r7r7ri:iiiiiiri7r7vYYjJuLJ2bqbgBQQQBs. .............................
i.i:iir7sUSSEEdqdPKJv7rruRBQBQBQBQBBBBBQBQBQQQQQBQQggZEPbqS22U2uUYv7777r7r7rrr7r7r7r7rrrriiiiirr7777LvJs1jusjuU1dQBQQBj..............................
:.:::::::::::ii77ss2SPqPDQQBQBBBQBQBQBQQQBQQRQRQQQMMZDEDdb5512121s7v777777rrr7r7r7r7rr77rrirr777r7r77L7LLJs1u1YsXQQQQBu..............................
:.::::::::i::::::::::::iYKQQBQBQBQBQQRQMQQQMQRQMQRMDMggPPXXII2511vsYsLYLYvv7777rrr7777777r7r7rrrrirr7r77vvLYuuuY5RQMBBv ..............................
PuYvrri:::...::::::i:i::i1RBBBQQQBQQQQQQQQRRMRgQQBQQgEKS2IU5IS5SuJu5U21uuuvv77rrrrrrr7rrr7r7r7r7rrrrirr77v7vvjssuRQQQBL. .............................
1LqqddEEd5I1j7ri::...::::YMBBQQQQQQQQQQQQRRMQggRQQgPXU2U5I5IXSX5SIKXPPKuvrriiii:iiiii:iirr77777iii:::irr7r7r7vY7uZQRBQ2..............................
:.:::irr7sUKSPPDEPIS2uvr:rIQQBQQQBQQQQQQRQMQRMgQREX2u21I55IXXKSqPPPdbEPXUusuvv77rriiii::...:::.... ..::ir777vUjsvPQRBZi...............................
i.i:i:i:::::i:iirrj2IUXXPUPQBQQQQQBQQRQMQRQMRMQRd5212UI2I5XXqqPdRgMgRMQQBQBQBQDKPuJJLriii....  ...ir7L25PPdXXXdX5XQBB7  .............................
:.:::::::i:i:::::::::::::72QBBQBBBQQQQMMQQRRDQQQqIUIUIU5ISXPqddEKSj1sYY5XPbEPEPPPqS2svr7r7rrii:irvs5SEMBQBQBQMdEPEMBDi ...............................
512vvrii:.::::::::i:i:i:::uBBBBBBQBQQMRgQRRMRRQbX25IX2I255X5X5X1s7ririrr77vvLvYLsYjYL77r7rrrrr7rLYU5XIXqPPDZDEZgQMRBP:...............................
LL15XbddqqSSujYvii::::::::rDQDbDQBBBRQMQRQMQQQMb55ISIS25252UujsYvLY7r7r7rriiir7v7v7Lvvr7rrr7r777vYYjLYvv77r7r7v12EQBv  ...............................
i.::::ii77LJ5KdPPqbPKu1J7iv2qKSuUqBBBQQRQRQQBRgPX25I5I512u2j1JsLYvL7rii:::::::irv7v777777rrrrrv7vvs77rriiiir7vY77JBBi ...............................
:.::::::::::::::i7r7vJ1UJSqEEdKquvLdQBBBQQRQQMdP55IS252511suYJvv777LssLjjUujYr:i7Yvvrrri:iirrvYJsJvr::...::irYYY7sBM. ................................
:.:.:.::::::i:::::i::::::YdEq221I1v71XdRBQQQBDZXS5SIIISIIJjsJs1u25bgBBBBBBBKgQZY7vuvrrr:::i:7vYs1vriYXEPSIULrr77vsB7  ...............................
b5U1jvii::::.:.::::::i::iUqKIXUYvjUJ7v1PZBQBMgqX5X5SI52S11LYvYjXPdEdPQBBBBq..7QB2r7vrrrririrrLLJ7vqBQBBBRsKBQbY77sgi .................................
L7U5PqPEMEbS51uv7ri::.:.rSP2UXjiirs2jYUUKRBMgbK5K5X5X252IJJv7777YLvvYvvJKUv7jjSbXirr7rv77rrrY1jiiSRBBBBBP.:1QBDj7vQL.................................
:.:::::rirrJJ22KPZPPqEKUUqK12XvrrsvS51USIMRdKPKKSX5S5SIXUUJYvLvv77777rrrrrrv77rii7rv7vvL7777vSqLrYY1XEPPIU1UU2I2LLbi .................................
:.i:::::::::::::iiir7vsY1XPU5YYuIKgMb5PSKDQdbXX5X5XISUI1Ussvvvsvv77777v777L777rirr7vv7YLvvL77YSJ7irrrr7rr777rrvvsY5: .................................
:..:...::::::i:i:::::::::1SIYJ1KPEX7jqXKKMMZKX5S5SISI2u2jJYY777v777v77r7r777rrrrrrrv7LYLLYvLvssY77r7rrr77v77777v7Yui .................................
bUqUsvLri::::::...:::::::rI2Yjq52Yriuj1UKgQbK5K5SIIUIuUU1ss77r77v7v7v777777r7r7rrr77vYJYJLLLsLY7v77rrirrrrrr7777vvJr.................................
7rLJuqbPSKqPIU1UsLrrii::..r2sIKXvrrsYvuSqMgdIS55I51U111UssLLrrirr77777777777r7r7rrrvvJuuJYvsvsLYvv7777r7r777777v7vLJ: ................................
:.::::::iirr77u2K5XXPPPSq55SSsSqvivLJvjSbEdKSIXS5II1Uj1jjLsv7rrrrrrr7r77vr7r7rriiivs1uU1UYvvYvsYJvv777v77777777777LJr................................
:.:::::::::::::::::iirrYJJv2P2YuuUKX12Y5PEPP5XXX5S1Ujuj1ssLYvv7rirr777r7r7riii::iL5K55U2jL7v777sJjriirirr7r7777v77vJr.................................
i.:.......::::i:i:::i::::::rKdK2UuUIKX22bKPSKXK5XIIuUj1jjsjLYL7iiirr7rriiii:i::72SXu1ujv7:.::..rsJr:i:iir7777r77v7LY7.................................
DqPq21svrri::....:.:::::::::rqKXIU77vJJXqqXqXqSX5S2I11J1JuJusY77rr:.:iirii:iirLKX1svriirr7iir::irLY7iiii:ir7777v7vvjr.................................
risY1IKPgMMPPPP2UJj7rii::....i5II1j7v7JUPPPqqSK5S5X2UJUu21Uj1Lv7vri.::rrr:iirLPXXjs77sPKXUYrrr7LsvLJvir:::irr777v7Lur................................
:.:::::::iirrYLu1SPbPdEgZP5IsvL5SUsuvvrv5bKqPqXXISI5U2UUuUjujL7L7rii:irriiiriY1UXP5KDBBBggbPSKRBBIJSLirrr::rir7v7LYs:.................................
:.::::::::::::::::::iiri77JjIUjuKPPSUYvYbdbPPXK5S5SIS2Uu1suJ1LY77rr:ir7rr:iiiiir7vIX2YYuI2PPXuPDZ52Lrirrriii7777vv1r.................................
:..:.......:.::::::::::::::::::::7jKPZERQQbbKK5S2II52IU2uuJjJYvL77riiririririiiri77s7vvUI7irirvY77rriiirii:rr77v7Js: .................................
DKEX2JJYYrri:::.:...:::::::::::::::.7gBgd2PdPKXIS252S2IUIuuJ1sLvvrrii:irrirrrr7rvYJYYYs7r77r77UusvL7riiiiiirr777LJr ..................................
ri7LLUUXXqPDEbI52UJYrrri::::::::::.:.IDSYs5EPPXXSSU5UI12UUuUJJLY77rriii7rrrr7v7L7YvYsusLvYvLvvJU1UJuvvirirr7r77LYY. ...................:..............
i.i:::::iii:rr7vJjIIIXdPqSqqP2Jvs77i:7DSUsIbDdPSS25UUU2UUu1JuJJ7vrrri:rrrrv7vr7777v777vrrr77vi7vsYjJ1Y7irrr7v7vv1r ...............:::::::::::.:::....
...::::::i:i:i:::::::::ii7rvvLs2Sq552XEP221dDZPXIIII1U1Uj1JjJ1Jv7rrriiirrLYv77rri7rrr77YsJYjLLvLvLvsLs7777r77v7JY:.:...:.::::::::::i:::::::::::::::::.
Jrrrr::::::::.::::::::i:i:i:i:i:::iiiijdKIIKZEdqK25U212U2UUuuYJvvrriririrv1u1JsjKqbEMRRgRDgZDDgEPU177LYLL77777Yu7.::::::::::::::::iiiiiiriiiiii:::i::.
SXZRgDPEbZq5uuLvrri:::.:.::::::::::i::7dqX2qdEbPqXI5UU1Uj2u1J1ss7777irr7sPZMgMgRDDddqX2I1IU21XPggDgDX2LLvv7777uI:::i:i:iiiii:iiiiiirr77v7v77r7rrrrii::
i.iiiir7YLu1XPDDRZDdRDEKX221J77rii:::.:uESS5dEDbPXK221U1UjUuIuJLv7L7rrvjX1JJUUX5K5XUJrrrririii7vuIPPZbKsvvv7vvSviirr7rrrrrrr7r7777v7LvYvLvLvvvL7v77rr:
:.:::::::::::::::iir7LL12XPZdDgRgRgZPbSDdPSKKEZEPPqK5S252I12uUJ1Y7r777vjv77v7LYjJ111Jvr7r7rrrr7Ys1Lssuus777vvIJri7r7777v7v7v7vvLvvvv7v7vvvvY7v7vvLvL7r
:.::::::::::::::::::i:i::::::iiir7LYU2UIgPPSXPZEZbdbPKXIS25UUu21uv7r7r7777v7vvsLYvYsUu2u1j1suYujuLsvv7L77777j2virr7r7r77v7v7v7vvLvv7v7v7vvvvL7YvLvLLY7
riii::.:.:::.::::::::::::::::i:iii:::i:iPDKXSXqZEdddqPKK5SI52I1IUjvvrrr7r77vvYvYLYvLvJJU1I1UjuYjLLLY7v777v7L1virr77777777v7v7v7v7v7v7v7v7v7vvLvYvLvLvv
ZqZPPKqqKu1Lv7rii:::....::::i:i:iiiii:::SZq5KSPPDEZPPqqKKS5ISIIUI11v7rrr77LYJLsYsLsvv77r77L7v777vLYvY7v7vvuuYirr7777v7v777v7v7v7v7v7vvv7LvLvvvLvv7LvY7
i:irrvsJY2IPdgZZPbEdIUJ1uj77rr:i::::::::JDXKXKSPbDgDbEPPKq5S55U51I1uv7r77v7LYJYJvYLsvv7v7v7v7vvYvYsJYY7vvjULirr77777777v7v7v7v7v7v7v7v7vvvvL7LvvvvvYv7
i.i:::::i:::::i:rrvLJj5XPKPPdbdqPS5IIUYrIZPKXIX5SKZEDEEddPbXq5SUI1IU1v7rrrrrvLsvYvsLsvLvv7Y777YYsYJYLvYLUUsrrr7r7r777777v77777v7v7v7v7vvLvvvvvvvYvLvL7
:.:i:i:i:i:::::::::::::::::iirr7rvJ22KXPPDPKSX5XI5KDDgZDdEPPPPX5U1jU1uv7irirrv777LLLvYvLvLvvrvvJLJvsvvYU2Yrrr7r7r7777777777v777v7v7vvv7Lvvvv7L7vvLvLv7
7:r:::::::::::::::::::::iii:::i:i:i:::i:7dEKX5X5X5X5bEMggdZPbPP5522uU1Uvv77rrrrrr7YvLL1U1vvY1JujjLLvLvJuvrrrrr7r7r7r777777v7v7v7v7v7vvvvLvLvLvL7L7vLY7
X5ZMgdSSI521sL77rri::::::::::::i:i:i:i::rdPqSK5SISI52IXggRggbPPPSK5SI522u1YL7777rvsuJUU5UUjSSIJ1ujvLvjuLirr7r7r7r7r777r77v7v7v7v7v7vvYvLvLvLvLvv7L7YL7
i.iirr77J121IIPPgDbKPqPXIsYvLv77rii::::.rPbXXIS25252S1U1qZQMREEPPPPPbqqXPS2sJvLvJj2UIISI52S5XU1JuYJsI5srrrrr7r7r77v77777v7v7v7v7v7vvvvvvvvLvvvvvvvLvs7
:.:::::::::::::::ir7vJsuuuuPPPXPqPZgPq1YugbPKKSXIS55I51UjU5PZQQRDDPdPdPqKP55U2uUjjsU15XqIX5qSPS1J1USXJrrr7r7r777r77v777v7v7v7v7v7v7v7vvLLvvv7L7L7v7YL7
:.::i:::::::i:::::::::::i:::::iirr77vYus5DdKPXKSqSSI5UI1UuuJ15EMBQQgZbbPbPdPbqKIIjuu12K5XSqSPPqISXdKLirr7r7r7r77v7v7v7v7v7v7v7v7v7vvL7LvY7vvLvYvLvLvY7
rirr:::::::::::::::::::::iii:iii:i:i:i::rEPPXKSKXS5522u2UIuujUuI5ZRBBQgZPddEPdPPSKSK5XSSISSXXPPPPbqJirrrr7r7r7777777777v7v7v7v7v7vvvvLvLLvvLvvvYvYvYvv
ZKPSKbdPP11uJYL7r:i:::::::::::i:i:i:ii::UDdXPKKSqIX5IU212j1u2UUJu1UXDRBQBMMDZEZbZdEPdKKSXXKXbZDdb55vrrrr7r7r7r7777v7v7v7v7v7v7v7v7v7v7Lvv7LvL7LvLvYvL7
i:iri77vLssU2PXX5KPEPP5SI5I5jv77rriiii:iPgPPqPKqKKSS2I1Uu1uU12122I1UjUKMBBBBBQRRggDgDggMgMZgdZKXI5Ijirr7r7r7r777777v7v7v7v7v7v7vvLvvvLvL7v7LvLvLvYvYLv
i.i:i:::::::::::iirrrr77suSIXISXPXqSSI25DdbPqKKXPSSI5UU12uUu22I2S2S2S1uY1IERBBBBBBBQBQRdPS52I25252SJrr7r7r7777v777v7v7v7v7v7vvvvv7LvL7vvLvLvvvLvYvYLY7
:.:i:iii:i:i:::i:::::i:i:i:i:iiii::rir5MdEPbKKXXXq5SU5221IU2121IUI2X5SIX5515KERBQBQQEPIU1IU52S2S22S2rrr7r7r777777v7v7v7v7v7v7LvLvv7v7v7L7L7LvLvYLYvYvv
siririiii::::::::::::iiiiiiiiii.::i..YgZbbbPPqqXK5X5X5X222IU52S2IISSqXPqbdEPPXSIS552S2SKPqPKKXX5SIKU7i7r7777v777v7v7v7v7vvvvLvv7LvvvvvL7L7vvLvLvLvLLY7
SIPdddXXXKSX21Ysv777irii:i::::.rIMBd2DbZPdPPqPXKSX5X5IuUjuYjJuJjsusuu1jUJjYJYJJJJ1122IU52I252I2SU5I57rr77777777v777v7vvvvvvYvvvL7L7L7LvL7Lvvvv7LvLvLL7
i.iiiirr77LvJjIIqqdPPXPKP1sLv75QBBBBQgZPPqPKqXK5SU212uuJjvYvL7vvv7vr7r7777vvYvsLjJ1sJsuu1ssYJsjj11I2sirr7r777777v777L7v7LvLvLvvvvvLvvvLvL7vvYvLvLvYvs7
i::i:::i:::i:i:::::i:iiri7ZQgBBQgRMQQQRRgMDdqK52jjsJLujussLYvv7v7v7v7v7v7vvLLYLsvsYssJYuJJsuJujuJUUS17irr7777v777v7v7L7LvvvLvYvLvvvv7LvLvLvvvYvYvYvYLL
i.::::::i:i:i:::i:i::....vBBBBQMRggDggQQBQBQQgMDDPX2jvvr7777vvv7v7v7v7v7v7v7vvLvv7LLYLJjusuJujuJ11215usriirrr77777vvv7v7vvLvv7vvL7vvv7vvL7v7vvYvYvLvL7
Yrrrrrii::::::::.:.::rsKPQRQQQQQQQMQgMZgDRgQQBQBQBBBQREdS2v7rrr77vvvvY7v7v7vvLvvvv7v7vvLvvvsvuJ1uU2IUSQBZKvriirrr77vvv7LvLvvvYvYvL7v7LvvvLvL7vvLLYvLv7
KIqSSXbqS1Jvv7777vuKRQBQBRgZMDMgRQBQBBBQBQBRQRRgQMQMQBBQBBBMgq2s7r7r7vLvvvLvv777v77777v7v7vvssjJ11UU2uqBBBQZPUuv7rr7v7vvY7LvLvYvLvLvv7LvLvvvvvYvYvYvY7
...:.ii7vIKgMRQBQBQQRMZgDMDgDgDgZgDggRMQRQQQQBQQQQRQMMgggMMBBBBBgPI1v7r7vsvLvv77r7rv7v7v7LvJYjjujUu2UUsPQBBBBQgRP1rrrrr7777v7v7v7LvLvLvvvYLYvYvLLYvsLv
v71UqbEZggggRgMggZgZDdZdZEggggMggggDggMgggMgRMRMQMQQQQBRRgRgRRQQBBBQMq5Yv7vvYvv77r7r77vvvvYYssjsuj1u2U2YSQBQQEZgQgES2sv77rrrrr777vvvLvYvLvsvYvsvsLsYY7
BRQQMgEEPdPbPEPdPZdEdDDgEZZgEDDggMgMgggMggDgZgDMgRggggDMgMgRgMggZMgRQBBQEKuYvv77iriiirrrrrr7r77v7vvYLsYLvIIPPddZbDgQgMDgDZPPS5jJvL7v7777r7r7r7r7r7r77r
*/
#include<bits/stdc++.h>
#define LL long long
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
using namespace std;
namespace IO
{
    const int sz=1<<15;
    char inbuf[sz],outbuf[sz];
    char *pinbuf=inbuf+sz;
    char *poutbuf=outbuf;
    inline char _getchar()
    {
        if (pinbuf==inbuf+sz)fread(inbuf,1,sz,stdin),pinbuf=inbuf;
        return *(pinbuf++);
    }
    inline void _putchar(char x)
    {
        if (poutbuf==outbuf+sz)fwrite(outbuf,1,sz,stdout),poutbuf=outbuf;
        *(poutbuf++)=x;
    }
    inline void flush()
    {
        if (poutbuf!=outbuf)fwrite(outbuf,1,poutbuf-outbuf,stdout),poutbuf=outbuf;
    }
}
inline int read(){
	int v=0,f=1;
	char c=getchar();
	while (c<'0' || c>'9'){
		if (c=='-') f=-1;
		c=getchar();
	}
	while (c>='0' && c<='9'){
		v=v*10+c-'0';
		c=getchar();
	}
	return v*f;
}

const int Maxn=100005;
const int B=605;
int n,b[Maxn],N,q;
struct Segtree{
	int L,R;
	vector<int> Ord[B*4],Pos[B*4];
	void Pull(int p){
		Ord[p].clear();Pos[p].clear();
		
		int j=0,Cp=Pos[p*2][0];
		for (int i=0;i<Ord[p*2].size();i++){
			//cerr<<"FK"<<Pos[p*2+1][j]<<' '<<Cp<<endl;
			while (j<Ord[p*2+1].size() && Pos[p*2+1][j]<=Cp){
				Ord[p].pb(Ord[p*2+1][j]);Pos[p].pb(Pos[p*2+1][j]);
				Cp++;j++;
			}
			//cerr<<"FKKKK"<<i<<" "<<Cp<<endl;
			Pos[p].pb(Cp);Ord[p].pb(Ord[p*2][i]);
			if (i!=Ord[p*2].size()-1){
				Cp+=Pos[p*2][i+1]-Pos[p*2][i];
			}
		}
		while (j<Ord[p*2+1].size()){
			Ord[p].pb(Ord[p*2+1][j]);Pos[p].pb(Pos[p*2+1][j]);
			j++;
		}
	}
	void build(int p,int l,int r){
		if (l==r){
			Ord[p].pb(l);
			Pos[p].pb(b[l]);
			//cerr<<"FK"<<l<<' '<<b[l]<<endl;
			return;
		}
		int mid=l+r>>1;
		build(p*2,l,mid);
		build(p*2+1,mid+1,r);
		Pull(p); 
		/*cerr<<"DEBUG"<<l<<' '<<r<<endl;
		for (int i=0;i<Ord[p].size();i++){
			cout<<Ord[p][i]<<' '<<Pos[p][i]<<endl; 
		}*/
	}
	void modify(int p,int l,int r,int pos){
		if (l==r){
			Pos[p][0]=b[l];
			return;
		}
		int mid=l+r>>1;
		if (pos<=mid){
			modify(p*2,l,mid,pos);
		} 
		else{
			modify(p*2+1,mid+1,r,pos);
		}
		Pull(p);
	}
	void build(){
		build(1,L,R);
	}
	void modify(int pos){
		modify(1,L,R,pos);
	}
}T[305];
int main(){
	n=read();
	for (int i=1;i<=n;i++) b[i]=read();
	for (int i=1;i<=n;i++) b[i]=i-b[i];
	
	q=read();
	N=(n-1)/B;
	for (int i=0;i<=N;i++){
		T[i].L=i*B+1;
		T[i].R=min(n,T[i].L+B-1);
		T[i].build();
	}
	
	while (q--){
		int tp=read();
		if (tp==1){
			int i,x;
			i=read();x=read();
			b[i]=i-x;
			int I=(i-1)/B;
			T[I].modify(i);
		}else{
			int i=read();
			int I=(i-1)/B;
			int ans=0;
			for (int j=0;j<T[I].Ord[1].size();j++){
				if (T[I].Ord[1][j]==i) ans=T[I].Pos[1][j];
			}
			
			for (int j=I+1;j<=N;j++){
				int lo=-1,hi=T[j].Pos[1].size();
				
				while (hi-lo>1){
					int mid=lo+hi>>1;
					if (ans+mid+1>T[j].Pos[1][mid]) lo=mid;
					else hi=mid;
				}
				ans+=lo+1;
			}
			
			printf("%d\n",ans);
		}
	}
}
/*
3
0 1 0
7
2 1
2 2
2 3
1 2 1
2 1
2 2
2 3
*/