#include<bits/stdc++.h>
using namespace std;
struct Node{
int l,r,lson,rson,val;
}tree[1919810*5];
int input[5*114514],val[5*114514],tot;
int root[5*114514];
void pushup(int p){
tree[p].val=tree[tree[p].lson].val+tree[tree[p].rson].val;
}
int build(int l,int r){
int p=++tot;
tree[p].l=l,tree[p].r=r;
if(l==r)return p;
int mid=(l+r)/2;
tree[p].lson=build(l,mid);
tree[p].rson=build(mid+1,r);
return p;
}
int modify(int oldp,int loc){
int p=++tot;
tree[p].l=tree[oldp].l,tree[p].r=tree[oldp].r;
tree[p].lson=tree[oldp].lson,tree[p].rson=tree[oldp].rson;
tree[p].val=tree[oldp].val;
if(tree[p].l==tree[p].r){
tree[p].val++;
return p;
}
int mid=(tree[p].l+tree[p].r)/2;
if(mid<=loc)tree[p].lson=modify(tree[oldp].lson,loc);
else tree[p].rson=modify(tree[oldp].rson,loc);
pushup(p);
return p;
}
int query(int lt,int rt,int loc){
if(tree[lt].l==tree[lt].r)return tree[lt].l;
int tmp=tree[tree[rt].lson].val-tree[tree[lt].lson].val;
if(tmp>=loc)return query(tree[lt].lson,tree[rt].lson,loc);
else return query(tree[lt].rson,tree[rt].rson,loc-tmp);
}
int main(){
int n,m;
cin>>n>>m;
for(int i=1;i<=n;i++){
cin>>input[i];
val[i]=input[i];
}
sort(val+1,val+n+1);
int tn=unique(val+1,val+n+1)-val-1;
root[0]=build(1,tn);
for(int i=1;i<=n;i++){
int loc=lower_bound(val+1,val+n+1,input[i])-val;
root[i]=modify(root[i-1],loc);
}
while(m--){
int l,r,k;
cin>>l>>r>>k;
cout<<val[query(root[l-1],root[r],k)]<<endl;
}
return 0;
}