#include <bits/stdc++.h>
using namespace std;
const int maxn = 200010;
int a[110];
int b[110];
int main() {
  int n, i, j;
  int m;
  cin >> n;
  for (i = 1; i <= n; i++) cin >> j, a[j] = i, b[i] = j;
  cin >> m;
  while (m--) {
    scanf("%d", &j);
    if (j == 1) {
      scanf("%d%d", &i, &j);
      int ans = 0;
      for (int k = i + 1; k <= j; k++)
        if (a[k] < a[k - 1]) ans++;
      cout << ans + 1 << endl;
    } else {
      scanf("%d%d", &i, &j);
      swap(b[i], b[j]);
      a[b[i]] = i;
      a[b[j]] = j;
    }
  }
}
