#include <bits/stdc++.h>
using namespace std;
struct vert;
typedef vert* vp;
struct vert {
  vp l, r;
  array<int, 4> dat;
  vert() : l(NULL), r(NULL) { dat = {0, 0, 0, 1}; }
};
array<int, 4> mergeD(array<int, 4>& a, array<int, 4>& b) {
  array<int, 4> res = {a[0], b[1], 0, a[3] + b[3]};
  res[2] = max(max(a[2], b[2]), a[1] + b[0]);
  if (a[2] == a[3]) res[0] = a[3] + b[0];
  if (b[2] == b[3]) res[1] = b[3] + a[1];
  return res;
}
vp merge(vp cl, vp cr) {
  vp v = new vert();
  v->dat = mergeD(cl->dat, cr->dat);
  v->l = cl, v->r = cr;
  return v;
}
vp build(int l, int r) {
  if (l == r) return new vert();
  int m = (l + r) / 2;
  return merge(build(l, m), build(m + 1, r));
}
vp upd(vp cv, int cl, int cr, int gi) {
  if (cl == cr) {
    vp nv = new vert();
    nv->dat = {1, 1, 1, 1};
    return nv;
  }
  int m = (cl + cr) / 2;
  if (gi > m)
    return merge(cv->l, upd(cv->r, m + 1, cr, gi));
  else
    return merge(upd(cv->l, cl, m, gi), cv->r);
}
array<int, 4> query(vp cv, int cl, int cr, int l, int r) {
  if (cl >= l && cr <= r) return cv->dat;
  int m = (cl + cr) / 2;
  array<int, 4> lr, rr;
  if (l <= m) lr = query(cv->l, cl, m, l, r);
  if (r > m) rr = query(cv->r, m + 1, cr, l, r);
  if (r <= m) return lr;
  if (l > m) return rr;
  return mergeD(lr, rr);
}
const int SZ = 1.1e5;
int n, q;
pair<int, int> sar[SZ];
vp sts[SZ];
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) cin >> sar[i].first, sar[i].second = i;
  sort(sar, sar + n);
  reverse(sar, sar + n);
  sts[0] = build(0, n - 1);
  for (int i = 0; i < n; i++) sts[i + 1] = upd(sts[i], 0, n - 1, sar[i].second);
  cin >> q;
  for (int i = 0; i < q; i++) {
    int l, r, w;
    cin >> l >> r >> w;
    int lo = 0, hi = n;
    while (lo != hi) {
      int m = (lo + hi) / 2;
      int resw = query(sts[m], 0, n - 1, l - 1, r - 1)[2];
      if (resw < w)
        lo = m + 1;
      else
        hi = m;
    }
    cout << sar[lo - 1].first << '\n';
  }
}
