#include<bits/stdc++.h>
using namespace std;
void read(int& x) {
x = 0;
bool y = false;
char ch = getchar();
while (ch < '0' || ch > '9') {
y = ch == '-';
ch = getchar();
}
while (ch >= '0' && ch <= '9') {
x = (x << 1) + (x << 3) + (ch ^ 48);
ch = getchar();
}
if (y) x = -x;
}
const int N=2e5+10;
int n,m,a[N],b[N],size;
struct Tree{
int l,r,data;
}tree[N<<6];
int root[N],ncnt;
void build_tree(int &u,int l,int r){
u=++ncnt;
if(l==r) return;
int mid=(l+r)>>1;
build_tree(tree[u].l,l,mid);
build_tree(tree[u].r,mid+1,r);
}
void insert(int pre,int &u,int l,int r,int to){
u=++ncnt;
tree[u]=tree[pre];
tree[u].data++;
if(l==r) return;
int mid=(l+r)>>1;
if(to<=mid) insert(tree[pre].l,tree[u].l,l,mid,to);
else insert(tree[pre].r,tree[u].r,mid+1,r,to);
}
int ask(int pre,int u,int l,int r,int k){
if(l==r) return l;
int mid=(l+r)>>1;
int dat=tree[u].data-tree[pre].data;
if(k<=dat) return ask(tree[pre].l,tree[u].l,l,mid,k);
else return ask(tree[pre].r,tree[u].r,mid+1,r,k-dat);
}
int main(){
read(n),read(m);
for(int i=1;i<=n;i++){
read(a[i]);
b[i]=a[i];
}
sort(b+1,b+1+n);
size=unique(b+1,b+1+n)-b-1;
build_tree(root[0],1,size);
for(int i=1;i<=n;i++){
a[i]=lower_bound(b+1,b+1+size,a[i])-b;
insert(root[i-1],root[i],1,size,a[i]);
}
for(int i=1;i<=m;i++){
int L,R,xx;
read(L),read(R),read(xx);
int id=ask(root[L-1],root[R],1,size,xx);
printf("%d\n",b[id]);
}
return 0;
}