#include<bits/stdc++.h>
using namespace std;
#define debug puts("YES");
#define rep(x,y,z) for(int (x)=(y);(x)<(z);(x)++)
#define ll long long
#define lrt int l,int r,int rt
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define mst(a,b) memset((a),(b),sizeof(a))
#define pii pair<int,int>
#define fi first
#define se second
#define mk(x,y) make_pair(x,y)
const int mod=1e9+7;
const int maxn=1e5+100;
const int ub=1e6;
const ll INF=1e18;
ll powmod(ll x,ll y){ll t; for(t=1;y;y>>=1,x=x*x%mod) if(y&1) t=t*x%mod; return t;}
ll gcd(ll x,ll y){
if(y==0) return x;
return gcd(y,x%y);
}
int n,q,b[maxn];///存储排序好的用来二分的
pii p[maxn];
///持久化线段树
int root[maxn],ch[maxn*30][2],tot=0;
struct N{
int maxv,lc,rc;
}node[maxn*30];
void update(int old,int &now,int l,int r,int pos){
now=++tot;
ch[now][0]=ch[old][0],ch[now][1]=ch[old][1];
node[now]=node[old];
if(l==r){node[now]=N{1,1,1};return ;}
int mid=l+r>>1;
if(pos<=mid) update(ch[old][0],ch[now][0],l,mid,pos);
if(mid<pos) update(ch[old][1],ch[now][1],mid+1,r,pos);
int x=ch[now][0],y=ch[now][1];
node[now].maxv=max(node[x].rc+node[y].lc,max(node[x].maxv,node[y].maxv));
node[now].lc=node[x].lc,node[now].rc=node[y].rc;
if(node[x].maxv==mid-l+1) node[now].lc+=node[y].lc;
if(node[y].maxv==r-mid) node[now].rc+=node[x].rc;
}
int query(int now,int l,int r,int L,int R){
if(L<=l&&r<=R) return node[now].maxv;
int mid=l+r>>1,ans=0;
if(L<=mid) ans=max(ans,query(ch[now][0],l,mid,L,R));
if(mid<R) ans=max(ans,query(ch[now][1],mid+1,r,L,R));
if(L<=mid&&mid<R){
int tmp=min(node[ch[now][0]].rc,mid-L+1)+min(R-mid,node[ch[now][1]].lc);
ans=max(ans,tmp);
}
return ans;
}
map<int,int> mp;
int l,r,ans,cnt;
int main(){/*
freopen("d://in.txt","r",stdin);
freopen("d://out.txt","w",stdout);*/
ios::sync_with_stdio(false);
cin>>n;
rep(i,1,n+1) {
int x;cin>>x;
b[i]=x;
p[i]=mk(-x,i);
}
sort(b+1,b+1+n);
cnt=unique(b+1,b+1+n)-b-1;
sort(p+1,p+1+n);
rep(i,1,n+1){
update(root[i-1],root[i],1,n,p[i].se);
p[i].fi=-p[i].fi;
mp[p[i].fi]=root[i];
}
cin>>q;
while(q--){
int x,y,w;
cin>>x>>y>>w;
l=1,r=cnt,ans=1;
while(l<=r){
int mid=l+r>>1;
if(query(mp[b[mid]],1,n,x,y)>=w) ans=mid,l=mid+1;
else r=mid-1;
}
cout<<b[ans]<<"\n";
}
return 0;
}