#include <bits/stdc++.h>
using namespace std;
const int maxN = 100 + 10;
int n, a[maxN], dp[maxN], p[maxN], q, t;
void make(int x, int y) {
  for (int i = 0; i < n; i++) p[a[i]] = i;
  dp[n] = 1;
  for (int i = n - 1; i > 0; i--) {
    if (p[i + 1] > p[i])
      dp[i] = dp[i + 1];
    else
      dp[i] = dp[i + 1] + 1;
  }
  cout << dp[x] - dp[y] + 1 << endl;
}
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  cin >> q;
  for (int i = 0; i < q; i++) {
    int x, y;
    cin >> t >> x >> y;
    if (t == 1)
      make(x, y);
    else
      swap(a[x - 1], a[y - 1]);
  }
  return 0;
}
