#include <bits/stdc++.h>
//Complete code at ideone.com/Tkters
//This code has comments and is for understanding the blog 
using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long
#define si(x)	scanf("%d",&x)
#define sl(x)	scanf("%lld",&x)
#define ss(s)	scanf("%s",s)
#define pi(x)	printf("%d\n",x)
#define pl(x)	printf("%lld\n",x)
#define ps(s)	printf("%s\n",s)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pl;
typedef vector<int>		vi;
typedef vector<ll>		vl;
typedef vector<pii>		vpii;
typedef vector<pl>		vpl;
typedef vector<vi>		vvi;
typedef vector<vl>		vvl;
int mpow(int base, int exp); 
void ipgraph(int m);
void dfs(int u, int par);
const int mod = 1000000007;
const int N = 3e5, M = N;
//=======================

vi g[N];
int a[N];
const int MAX = 1e6;
struct wavelet_tree{
	#define vi vector<int>
	#define pb push_back
	int lo, hi;
	wavelet_tree *l, *r;
	vi b;
	
	//nos are in range [x,y]
	//array indices are [from, to)
	wavelet_tree(int *from, int *to, int x, int y){
		lo = x, hi = y;
		if(lo == hi or from >= to) return;
		
		int mid = (lo+hi)/2;
		auto f = [mid](int x){
			return x <= mid;
		};
		b.reserve(to-from+1);
		b.pb(0);
		//b[i] = no of elements from first "i" elements that go to left node
		for(auto it = from; it != to; it++)
			b.pb(b.back() + f(*it));
		
		//see how lambda function is used here	
		auto pivot = stable_partition(from, to, f);
		l = new wavelet_tree(from, pivot, lo, mid);
		r = new wavelet_tree(pivot, to, mid+1, hi);
	}
	
	//kth smallest element in [l, r]
	int kth(int l, int r, int k){
		if(l > r) return 0;
		if(lo == hi) return lo;
		//how many nos are there in left node from [l, r]
		int inleft = b[r] - b[l-1];
		int lb = b[l-1]; //amt of nos from first (l-1) nos that go in left 
		int rb = b[r]; //amt of nos from first (r) nos that go in left
		//so [lb+1, rb] represents nos from [l, r] that go to left
		if(k <= inleft) return this->l->kth(lb+1, rb , k);
		
		//(l-1-lb) is amt of nos from first (l-1) nos that go to right
		//(r-rb) is amt of nos from first (r) nos that go to right
		//so [l-lb, r-rb] represents nos from [l, r] that go to right
		return this->r->kth(l-lb, r-rb, k-inleft);
	}
	~wavelet_tree(){
		delete l;
		delete r;
	}
	
};
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	srand(time(NULL));
	int i,n,k,j,q,l,r;
	cin >> n;
	fo(i, n) cin >> a[i+1];
	wavelet_tree T(a+1, a+n+1, 1, MAX);
	cin >> q;
	while(q--){
		cin >> l >> r >> k;
		cout << T.kth(l, r, k) << endl;
	}
	return 0;
} 

