#include <bits/stdc++.h>
using namespace std;
int n, k, res, o, x, y, a[10000];
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  cin >> k;
  for (int i = 1; i <= k; i++) {
    cin >> o >> x >> y;
    if (o == 2) {
      swap(a[x], a[y]);
      continue;
    }
    res = 0;
    int xx = x;
    for (int j = x; j <= y; j++) {
      for (int w = 1; w <= n; w++)
        if (a[w] == xx) xx++;
      res++;
      if (xx > y) break;
    }
    cout << res << "\n";
  }
  return 0;
}
