#include <bits/stdc++.h>
using namespace std;
using LL = long long;
constexpr int N = 1e5 + 5;
int n;
int in[N];
void solve(int x, int y) {
  int res = 0;
  while (x <= y) {
    res++;
    for (int i = 1; i <= n; i++) {
      if (in[i] == x) x++;
    }
  }
  cout << res << "\n";
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> in[i];
  int q;
  cin >> q;
  while (q--) {
    int p, x, y;
    cin >> p >> x >> y;
    if (p == 1) {
      solve(x, y);
    } else {
      swap(in[x], in[y]);
    }
  }
}
