#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#define space putchar(' ')
#define enter putchar('\n')
using namespace std;
typedef long long ll;
template <class T>
void read(T &x){
char c;
bool op = 0;
while(c = getchar(), c < '0' || c > '9')
if(c == '-') op = 1;
x = c - '0';
while(c = getchar(), c >= '0' && c <= '9')
x = x * 10 + c - '0';
if(op) x = -x;
}
template <class T>
void write(T x){
if(x < 0) putchar('-'), x = -x;
if(x >= 10) write(x / 10);
putchar('0' + x % 10);
}
const int N = 500005, M = 100005;
int n, m, cur, ans[M], tr[N];
struct query {
int id, l, r, k;
} q[M], tmp[M];
struct element {
int pos, val;
bool operator < (const element &obj) const{
return val < obj.val;
}
} b[N];
void add(int p, int x){
while(p <= n) tr[p] += x, p += p & -p;
}
int ask(int p){
int ret = 0;
while(p) ret += tr[p], p -= p & -p;
return ret;
}
void solve(int l, int r, int ql, int qr){
if(ql > qr) return;
if(l == r){
for(int i = ql; i <= qr; i++)
ans[q[i].id] = b[l].val;
return;
}
int mid = (l + r) >> 1, cnt = 0;
for(int i = l; i <= mid; i++)
add(b[i].pos, 1);
for(int i = ql; i <= qr; i++)
if(ask(q[i].r) - ask(q[i].l - 1) >= q[i].k) cnt++;
for(int i = ql, p1 = ql, p2 = ql + cnt; i <= qr; i++){
int sum = ask(q[i].r) - ask(q[i].l - 1);
if(ask(q[i].r) - ask(q[i].l - 1) >= q[i].k) tmp[p1++] = q[i];
else q[i].k -= sum, tmp[p2++] = q[i];
}
for(int i = ql; i <= qr; i++)
q[i] = tmp[i];
for(int i = l; i <= mid; i++)
add(b[i].pos, -1);
solve(l, mid, ql, ql + cnt - 1);
solve(mid + 1, r, ql + cnt, qr);
}
int main(){
read(n), read(m);
for(int i = 1; i <= n; i++)
read(b[i].val), b[i].pos = i;
sort(b + 1, b + n + 1);
for(int i = 1; i <= m; i++)
q[i].id = i, read(q[i].l), read(q[i].r), read(q[i].k);
solve(1, n, 1, m);
for(int i = 1; i <= m; i++)
write(ans[i]), enter;
return 0;
}