#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
int n, q;
int a[N];
int l[N], r[N], w[N];
struct Node {
  int mxlen, pref, suff, len;
  Node(int mxlen = 0, int pref = 0, int suff = 0, int len = 0)
      : mxlen(mxlen), pref(pref), suff(suff), len(len) {}
} t[N << 2];
Node merge(Node lef, Node rig) {
  Node res;
  res.mxlen = max(max(lef.mxlen, rig.mxlen), lef.suff + rig.pref);
  res.pref = lef.pref == lef.len ? lef.len + rig.pref : lef.pref;
  res.suff = rig.suff == rig.len ? rig.len + lef.suff : rig.suff;
  res.len = lef.len + rig.len;
  return res;
}
void build(int v, int l, int r) {
  if (l == r) {
    t[v] = Node(0, 0, 0, 1);
    return;
  }
  build((v << 1), l, ((l + r) >> 1));
  build((v << 1 | 1), ((l + r) >> 1) + 1, r);
  t[v] = merge(t[(v << 1)], t[(v << 1 | 1)]);
}
void upd(int v, int l, int r, int pos) {
  if (l > pos || r < pos) return;
  if (l == r) {
    t[v] = Node(1, 1, 1, 1);
    return;
  }
  upd((v << 1), l, ((l + r) >> 1), pos);
  upd((v << 1 | 1), ((l + r) >> 1) + 1, r, pos);
  t[v] = merge(t[(v << 1)], t[(v << 1 | 1)]);
}
Node get(int v, int l, int r, int lef, int rig) {
  if (lef > r || rig < l) return Node(0, 0, 0, 0);
  if (lef <= l && rig >= r) return t[v];
  return merge(get((v << 1), l, ((l + r) >> 1), lef, rig),
               get((v << 1 | 1), ((l + r) >> 1) + 1, r, lef, rig));
}
int lo[N], hi[N];
vector<pair<int, int> > h;
vector<pair<int, int> > vec;
void calc() {
  vec.clear();
  build(1, 1, n);
  for (int i = 1; i <= q; ++i)
    if (lo[i] < hi[i]) {
      vec.push_back(make_pair((lo[i] + hi[i]) >> 1, i));
    }
  sort(vec.begin(), vec.end());
  int pt = 0;
  for (int i = 0; i < vec.size(); ++i) {
    int val = vec[i].first, pos = vec[i].second;
    while (pt <= val && pt < n) upd(1, 1, n, h[pt].second), pt++;
    int mxlen = get(1, 1, n, l[pos], r[pos]).mxlen;
    if (mxlen >= w[pos])
      hi[pos] = val;
    else
      lo[pos] = val + 1;
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n;
  for (int i = 1; i <= n; ++i) cin >> a[i];
  for (int i = 1; i <= n; ++i) h.push_back(make_pair(a[i], i));
  sort(h.begin(), h.end());
  reverse(h.begin(), h.end());
  cin >> q;
  for (int i = 1; i <= q; ++i) cin >> l[i] >> r[i] >> w[i];
  for (int i = 1; i <= q; ++i) lo[i] = 0, hi[i] = n - 1;
  for (int i = 1; i <= 17; ++i) calc();
  for (int i = 1; i <= q; ++i) cout << h[lo[i]].first << '\n';
}
