#include <bits/stdc++.h>
using namespace std;
const int maxn = 100005;
const int maxl = maxn * 20;
int lc[maxl], rc[maxl], tt, lk[maxl], rk[maxl], mk[maxl];
int root[maxn], las[maxn];
void build(int l, int r, int& rt) {
  rt = ++tt;
  lk[rt] = rk[rt] = mk[rt] = 0;
  if (l == r) return;
  int m = (l + r) >> 1;
  build(l, m, lc[rt]);
  build(m + 1, r, rc[rt]);
}
void pushup(int l, int r, int rt) {
  int m = (l + r) >> 1, ls = lc[rt], rs = rc[rt];
  lk[rt] = lk[ls];
  if (lk[rt] == m - l + 1) lk[rt] += lk[rs];
  rk[rt] = rk[rs];
  if (rk[rt] == r - m) rk[rt] += rk[ls];
  mk[rt] = max(max(mk[ls], mk[rs]), rk[ls] + lk[rs]);
}
void inser(int p, int l, int r, int& rt, int f) {
  rt = ++tt;
  if (l == r) {
    lk[rt] = rk[rt] = mk[rt] = 1;
    return;
  }
  lc[rt] = lc[f];
  rc[rt] = rc[f];
  int m = (l + r) >> 1;
  if (p <= m)
    inser(p, l, m, lc[rt], lc[f]);
  else
    inser(p, m + 1, r, rc[rt], rc[f]);
  pushup(l, r, rt);
}
int n, q, h[maxn], tot;
struct node {
  int x, id;
  node(int a, int b) : x(a), id(b) {}
  bool operator<(const node& a) const { return x > a.x; }
};
vector<int> vs;
int f(int x) { return lower_bound(vs.begin(), vs.end(), x) - vs.begin(); }
struct seg {
  int ma[maxn << 2], mi[maxn << 2];
  void build(int l, int r, int rt) {
    if (l == r) {
      ma[rt] = mi[rt] = f(h[l]);
      return;
    }
    int m = (l + r) >> 1;
    build(l, m, rt << 1);
    build(m + 1, r, rt << 1 | 1);
    ma[rt] = max(ma[rt << 1], ma[rt << 1 | 1]);
    mi[rt] = min(mi[rt << 1], mi[rt << 1 | 1]);
  }
  int qma(int ql, int qr, int l, int r, int rt) {
    if (ql <= l && r <= qr) return ma[rt];
    int m = (l + r) >> 1, res = 0;
    if (ql <= m) res = max(res, qma(ql, qr, l, m, rt << 1));
    if (qr > m) res = max(res, qma(ql, qr, m + 1, r, rt << 1 | 1));
    return res;
  }
  int qmi(int ql, int qr, int l, int r, int rt) {
    if (ql <= l && r <= qr) return mi[rt];
    int m = (l + r) >> 1, res = maxn;
    if (ql <= m) res = min(res, qmi(ql, qr, l, m, rt << 1));
    if (qr > m) res = min(res, qmi(ql, qr, m + 1, r, rt << 1 | 1));
    return res;
  }
} st;
vector<node> v;
struct co {
  int lk, rk, mk, si;
  co() {}
  co(int a, int b, int c, int d) : lk(a), rk(b), mk(c), si(d) {}
};
vector<co> vq;
co u(co a, co b) {
  co c;
  c.lk = a.lk;
  if (c.lk == a.si) c.lk += b.lk;
  c.rk = b.rk;
  if (c.rk == b.si) c.rk += a.rk;
  c.mk = max(max(a.mk, b.mk), a.rk + b.lk);
  c.si = a.si + b.si;
  return c;
}
void query(int ql, int qr, int l, int r, int rt) {
  if (ql <= l && r <= qr) {
    vq.push_back(co(lk[rt], rk[rt], mk[rt], r - l + 1));
    return;
  }
  int m = (l + r) >> 1;
  if (ql <= m) query(ql, qr, l, m, lc[rt]);
  if (qr > m) query(ql, qr, m + 1, r, rc[rt]);
}
int ql, qr, w;
bool yes(int x) {
  int p = las[x];
  vq.clear();
  query(ql, qr, 1, n, root[p]);
  for (int i = 1; i < vq.size(); i++) vq[i] = u(vq[i - 1], vq[i]);
  return vq[vq.size() - 1].mk >= w;
}
void sol() {
  scanf("%d%d%d", &ql, &qr, &w);
  int l = st.qmi(ql, qr, 1, n, 1), r = st.qma(ql, qr, 1, n, 1), res;
  while (l <= r) {
    int m = (l + r) >> 1;
    if (yes(m)) {
      res = m;
      l = m + 1;
    } else
      r = m - 1;
  }
  printf("%d\n", vs[res]);
}
int main() {
  scanf("%d", &n);
  vs.push_back(0);
  for (int i = 1; i <= n; i++) {
    scanf("%d", h + i);
    v.push_back(node(h[i], i));
    vs.push_back(h[i]);
  }
  sort(vs.begin(), vs.end());
  vs.erase(unique(vs.begin(), vs.end()), vs.end());
  build(1, n, root[0]);
  st.build(1, n, 1);
  sort(v.begin(), v.end());
  for (int i = 0; i < n; i++) {
    inser(v[i].id, 1, n, root[i + 1], root[i]);
    las[f(v[i].x)] = i + 1;
  }
  scanf("%d", &q);
  while (q--) sol();
}
