#include <bits/stdc++.h>
using namespace std;
int n, q, x, y, p;
int a[105];
int main() {
  cin >> n;
  for (int i = (1), _b = (n); i <= _b; i++) cin >> a[i];
  cin >> q;
  for (int i = 0, _n = (q); i < _n; i++) {
    cin >> p >> x >> y;
    if (p == 1) {
      int ans = 0;
      int k = x;
      while (k <= y) {
        for (int j = 1; j <= n; j++) {
          if (a[j] == k) {
            k++;
          }
        }
        ans++;
      }
      cout << ans << endl;
    } else
      swap(a[x], a[y]);
  }
  return 0;
}
