#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
enum Query
{
    Min = 0,
    Max = 1,
};
std::istream &operator>>(std::istream &is, Query &i)
{
    int tmp;
    if (is >> tmp)
        i = static_cast<Query>(tmp);
    return is;
} //オペレーターオーバーロード
int main()
{
    vector<int> A;

    int n;
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        int a;
        cin >> a;
        A.push_back(a);
    }

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