#include <bits/stdc++.h>
using namespace std;
#define REP(i, a, b) for (int i = (a), _end_ = (b); i <= _end_; ++i)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define mp make_pair
#define x first
#define y second
#define pb push_back
#define SZ(x) (int((x).size()))
#define ALL(x) (x).begin(), (x).end()
template<typename T> inline bool chkmin(T &a, const T &b){ return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b){ return a < b ? a = b, 1 : 0; }
typedef long long LL;
const int dmax = 300100, oo = 0x3f3f3f3f;
int n, m;
struct node
{
int l, r, w;
node(int l = 0, int r = 0, int w = 0): l(l), r(r), w(w) {}
};
node t[dmax * 7];
int a[dmax], b[dmax], root[dmax], cnt = 0;
#define left l, mid
#define right mid + 1, r
template<typename T> inline T Mid(const T &x, const T &y){ return (x + y) >> 1; }
void create(int l, int r, int& k)
{
k = cnt++;
t[k] = node(0, 0, 0);
if (l == r) return;
int mid = Mid(l, r);
create(left, t[k].l);
create(right, t[k].r);
}
void update(int i, int x, int l, int r, int &k)
{
k = cnt++;
t[k] = node(t[i].l, t[i].r, t[i].w + 1);
if (l == r) return;
int mid = Mid(l, r);
if (x <= mid)
update(t[i].l, x, left, t[k].l);
else update(t[i].r, x, right, t[k].r);
}
int query(int i, int j, int l, int r, int k)
{
int mid = Mid(l, r);
if (l == r) return mid;
int T = t[t[j].l].w - t[t[i].l].w;
if (k <= T)
query(t[i].l, t[j].l, left, k);
else query(t[i].r, t[j].r, right, k - T);
}
int main()
{
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
scanf("%d%d", &n, &m);
REP(i, 1, n)
{
scanf("%d", &a[i]);
b[i] = a[i];
}
sort(b + 1, b + n + 1);
int num = unique(b + 1, b + n + 1) - b - 1;
create(1, num, root[0]);
REP(i, 1, n)
{
a[i] = lower_bound(b + 1, b + num + 1, a[i]) - b;
update(root[i - 1], a[i], 1, num, root[i]);
}
while (m--)
{
int x, y, k;
scanf("%d%d%d", &x, &y, &k);
printf("%d\n", b[query(root[x - 1], root[y], 1, num, k)]);
}
return 0;
}