#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <queue>
using namespace std;
typedef long long ll;
const int INF = 1<<30; 
const int MOD = 1e9 + 7;
const int dy[] = {1, 0, -1, 0};
const int dx[] = {0, 1, 0, -1};
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int A[n + 1];
    for(int i = 0; i < n; i++) cin >> A[i];
    int q;
    cin >> q;
    for(int i = 0; i < q; i++)
    {
        int com, b, e;
        int ans;
        cin >> com >> b >> e;
        if(com == 0)
        {
            ans = INF;
            for(int i = b; i < e; i++) ans = min(A[i], ans);
        }
        else if(com == 1)
        {
            ans = -INF;
            for(int i = b; i < e; i++) ans = max(A[i], ans);
        }
        cout << ans << "\n";
    }
    return 0;
}


