#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e18;
const long long maxn = 1e5 + 10;
const long long mod = 1e9 + 7;
long long n, q, k;
struct node {
  long long ps, sf, ans;
  node() {
    ps = 0;
    sf = 0;
    ans = 0;
  }
} seg[maxn * 32];
long long L[maxn * 32], R[maxn * 32];
long long lst = 1, root[maxn];
void build(long long v = 1, long long tl = 1, long long tr = n) {
  if (tl == tr) return;
  long long tm = (tl + tr) >> 1;
  L[v] = ++lst;
  R[v] = ++lst;
  build(L[v], tl, tm);
  build(R[v], tm + 1, tr);
}
node up(node A, node B, long long l, long long r, long long tm) {
  node res;
  res.ans = max({A.ans, B.ans, A.sf + B.ps});
  res.ps = A.ps;
  if (A.ps == (tm - l + 1)) res.ps += B.ps;
  res.sf = B.sf;
  if (B.sf == (r - tm)) res.sf += A.sf;
  return res;
}
void upd(long long pos, long long v, long long id, long long tl = 1,
         long long tr = n) {
  if (tl == tr) {
    seg[v].ps = 1;
    seg[v].sf = 1;
    seg[v].ans = 1;
    return;
  }
  long long tm = (tl + tr) >> 1;
  if (pos <= tm) {
    if (L[v] == 0 || L[v] == L[id]) L[v] = ++lst;
    if (R[v] == 0) R[v] = R[id];
    upd(pos, L[v], L[id], tl, tm);
  } else {
    if (L[v] == 0) L[v] = L[id];
    if (R[v] == 0 || R[v] == R[id]) R[v] = ++lst;
    upd(pos, R[v], R[id], tm + 1, tr);
  }
  seg[v] = up(seg[L[v]], seg[R[v]], tl, tr, tm);
}
node qu(long long l, long long r, long long v, long long tl = 1,
        long long tr = n) {
  if (tl == l && tr == r) return seg[v];
  long long tm = (tl + tr) >> 1;
  if (r <= tm) return qu(l, r, L[v], tl, tm);
  if (l >= tm + 1) return qu(l, r, R[v], tm + 1, tr);
  return up(qu(l, tm, L[v], tl, tm), qu(tm + 1, r, R[v], tm + 1, tr), l, r, tm);
}
long long a[maxn], rmp[maxn];
vector<long long> ve, X[maxn];
long long mp(long long x) {
  return upper_bound(ve.begin(), ve.end(), x) - ve.begin();
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (long long i = 1; i <= n; i++) {
    cin >> a[i];
    ve.push_back(a[i]);
  }
  sort(ve.begin(), ve.end());
  ve.resize(unique(ve.begin(), ve.end()) - ve.begin());
  long long LST = 0;
  for (auto x : ve) rmp[++LST] = x;
  for (long long i = 1; i <= n; i++) {
    a[i] = mp(a[i]);
    X[a[i]].push_back(i);
  }
  root[(long long)ve.size() + 1] = 1;
  build();
  for (long long i = (long long)ve.size(); i >= 1; i--) {
    root[i] = ++lst;
    for (auto x : X[i]) {
      upd(x, root[i], root[i + 1]);
    }
  }
  cin >> q;
  for (long long i = 1, l, r, w; i <= q; i++) {
    cin >> l >> r >> w;
    long long hi = (long long)ve.size() + 1, lo = 0;
    while (hi - lo > 1) {
      long long mid = (hi + lo) >> 1;
      long long XX = qu(l, r, root[mid]).ans;
      if (XX >= w)
        lo = mid;
      else
        hi = mid;
    }
    cout << rmp[lo] << "\n";
  }
}
