#include <bits/stdc++.h>
using namespace std;
struct Query {
int l, r; // [l, r)
int val, count_le;
int ans_range_l, ans_range_r;
int ans_mid() const {
return ans_range_l + (ans_range_r - ans_range_l) / 2;
}
};
const int maxn = 100010;
const int maxq = 5050;
const int inf = (int)1e9 + 100;
int n, q;
pair<int, int> a[maxn];
Query qr[maxq];
vector<int> val_it[maxn * 2];
int main() {
#ifdef LOCAL
freopen("main.inp", "r", stdin);
freopen("main.out", "w", stdout);
#endif
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cin >> n >> q;
for (int i = 0; i < n; ++i) {
cin >> a[i].first;
a[i].second = i;
}
for (int i = 0; i < q; ++i) {
cin >> qr[i].l >> qr[i].r >> qr[i].val;
--qr[i].l;
qr[i].ans_range_l = -inf;
qr[i].ans_range_r = inf;
}
sort(a, a + n);
for (int i = 0; i < n; ++i) {
for (int p = a[i].second + n; p > 0; p >>= 1)
val_it[p].push_back(a[i].first);
}
while (true) {
vector<Query*> temp_qr;
for (int i = 0; i < q; ++i) {
if (qr[i].ans_range_l == qr[i].ans_range_r) continue;
qr[i].count_le = 0;
temp_qr.push_back(qr + i);
}
if (temp_qr.empty()) break;
sort(temp_qr.begin(), temp_qr.end(), [](const Query* u, const Query* v) {
return u->ans_mid() < v->ans_mid();
});
vector<vector<Query*>> qr_it(2 * n);
for (auto cur_qr: temp_qr) {
for (int l = cur_qr->l + n, r = cur_qr->r + n; l < r; l >>= 1, r >>= 1) {
if (l & 1) qr_it[l++].push_back(cur_qr);
if (r & 1) qr_it[--r].push_back(cur_qr);
}
}
for (int root = 1; root < 2 * n; ++root) {
auto& vi = val_it[root];
auto& qi = qr_it[root];
if (vi.empty() or qi.empty()) continue;
int ptr_v = 0;
for (auto cur_qr: qi) {
while (ptr_v < (int)vi.size() and vi[ptr_v] <= cur_qr->ans_mid()) ++ ptr_v;
cur_qr->count_le += ptr_v;
}
}
for (int i = 0; i < q; ++i) {
if (qr[i].ans_range_l == qr[i].ans_range_r) continue;
if (qr[i].count_le >= qr[i].val) {
qr[i].ans_range_r = qr[i].ans_mid();
} else {
qr[i].ans_range_l = qr[i].ans_mid() + 1;
}
}
}
for (int i = 0; i < q; ++i) cout << qr[i].ans_range_l << '\n';
return 0;
}