#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9 + 5143;
const long long Linf = 1e18 + 5413;
template <class T>
inline void umax(T &a, T b) {
  if (a < b) a = b;
}
template <class T>
inline void umin(T &a, T b) {
  if (a > b) a = b;
}
template <class T>
inline T abs(T a) {
  return a > 0 ? a : -a;
}
template <class T>
inline T lcm(T a, T b) {
  return a / __gcd(a, b) * b;
}
inline int read() {
  int res = 0;
  int neg;
  while (true) {
    char ch = getchar();
    if (ch >= '0' && ch <= '9' || ch == '-') {
      if (ch == '-')
        neg = -1;
      else
        neg = 1, res = ch - '0';
      break;
    }
  }
  while (true) {
    char ch = getchar();
    if (ch >= '0' && ch <= '9')
      res *= 10, res += ch - '0';
    else
      break;
  }
  return res * neg;
}
const int MAXN = 110;
int ar[MAXN];
int pos[MAXN];
int solve(int l, int r) {
  if (l == r) return 1;
  int res = 0;
  for (int(i) = (l + 1); (i) <= (r); (i)++) {
    if (ar[i - 1] > ar[i]) res++;
  }
  return res + 1;
}
int main() {
  int N = read();
  for (int(i) = (1); (i) <= (N); (i)++) {
    int a = read();
    ar[a] = i;
    pos[i] = a;
  }
  int Q = read();
  while (Q--) {
    int t = read();
    int x = read();
    int y = read();
    if (t == 1) {
      printf("%d\n", solve(x, y));
    } else {
      swap(ar[pos[x]], ar[pos[y]]);
      swap(pos[x], pos[y]);
    }
  }
  return 0;
}
