#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;

int main() {
  int n, q;
  cin >> n;

  vector<int> a(n);
  for (int i = 0; i < n; ++i)
    cin >> a[i];

  cin >> q;
  for (int i = 0; i < q; ++i) {
    int com, b, e;
    cin >> com >> b >> e;

    if (com == 0) {
      int mn = 1e9;
      for (int j = b; j < e; ++j)
        mn = min(mn, a[j]);
      cout << mn << endl;
    } else {
      int mx = -1e9;
      for (int j = b; j < e; ++j)
        mx = max(mx, a[j]);
      cout << mx << endl;
    }
  }
}
