#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main()
{
    long long n, q;
    cin >> n;
    vector<long long> a(n);
    
    for(int i=0;i<n;i++)
        cin >> a[i];

    cin >> q;
    for (int i = 0; i < q; i++)
    {
        long long com,b,e;
        cin >> com >> b >> e;
        if(com == 0)
            cout << *min_element(a.begin()+b,a.begin()+e) << endl;
        else if (com == 1)
            cout << *max_element(a.begin() + b, a.begin() + e) << endl;
    }

    return 0;
}
