#include <bits/stdc++.h>
using namespace std;
const int MAXN = 200;
int a[MAXN], n;
int d[MAXN];
int calc_ans(int x, int y) {
  memset(d, 0, sizeof d);
  for (int i = n; i >= 1; i--)
    for (int j = i + 1; j <= n; j++)
      if (a[j] - a[i] == 1) {
        d[a[i]] = d[a[j]] + 1;
        break;
      }
  int ans = 0;
  while (x <= y) {
    x += d[x] + 1;
    ans++;
  }
  return ans;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  int q;
  cin >> q;
  for (int i = 0; i < q; i++) {
    int p, x, y;
    cin >> p >> x >> y;
    if (p == 2)
      swap(a[x], a[y]);
    else
      cout << calc_ans(x, y) << endl;
  }
  return 0;
}
