intread(){ int x = 0; char c = gc(); while (!isdigit(c)) c = gc(); while (isdigit(c)) x = x * 10 + c - '0', c = gc(); return x; }
int n, m, a[maxn];
int blo, num, d[maxn], p[maxn], l[maxs], r[maxs], bl[maxn]; voidinit_blo(){ blo = sqrt(n); num = n / blo; if (n % blo) ++num; for (int i = 1; i <= n; ++i) bl[i] = (i - 1) / blo + 1; for (int i = 1; i <= num; ++i) { l[i] = (i - 1) * blo + 1; r[i] = i * blo; } r[num] = n; for (int i = num; i; --i) for (int j = r[i]; j >= l[i]; --j) { if (j + a[j] > r[i]) { p[j] = j + a[j]; d[j] = 1; continue; } d[j] = d[j + a[j]] + 1; p[j] = p[j + a[j]]; } }
intquery(int k){ int ans = 0; while (k <= n) ans += d[k], k = p[k]; return ans; }
voidupdate(int k, int v){ int bk = bl[k]; a[k] = v; for (int i = r[bk]; i >= l[bk]; --i) { if (i + a[i] > r[bk]) { p[i] = i + a[i]; d[i] = 1; continue; } d[i] = d[i + a[i]] + 1; p[i] = p[i + a[i]]; } }
inlinevoidsolve_1(){ int x = read() + 1; printf("%d\n", query(x)); }
inlinevoidsolve_2(){ int x = read() + 1, y = read(); update(x, y); }
intmain(){ n = read(); for (int i = 1; i <= n; ++i) a[i] = read(); init_blo(); m = read(); for (int i = 1; i <= m; ++i) { int opt = read(); switch (opt) { case1 : solve_1(); break; case2 : solve_2(); break; } } return0; }