#include<iostream>
#include<algorithm>
#define int long long
using namespace std;
int n, a[1010], q, b, e, k;
signed main() {
	cin >> n; for (int i = 0; i < n; i++)cin >> a[i];
	cin >> q;
	for (int i = 0; i < q; i++) {
		cin >> k >> b >> e;
		int ans = a[b];
		for (int j = b + 1; j < e; j++)if (!k)ans = min(ans, a[j]); else ans = max(ans, a[j]);
		cout << ans << endl;
	}
}
