#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;
typedef long long int ll;

int main(){
    vector<ll> v;
    int n, q;
    ll t, r;
    int c, b, e;
    scanf("%d", &n);
    for (int i = 0; i < n; i++){
        scanf("%lld", &t);
        v.push_back(t);
    }
    scanf("%d", &q);
    auto itr = v.begin();
    for (int i = 0; i < q; i++){
        scanf("%d %d %d", &c, &b, &e);
        if(c == 0){ // min
            r = *min_element(itr+b, itr+e);
        }else{  // max
            r = *max_element(itr+b, itr+e);
        }
        printf("%lld\n", r);
    }
}
