#include <bits/stdc++.h>
using namespace std;
struct elem {
  int ma, le, ri;
  elem(int ma = 0, int le = 0, int ri = 0) : ma(ma), le(le), ri(ri) {}
};
pair<int, int> x[100005];
int lp[3000006];
int rp[3000006];
int sz = 1;
elem tr[3000006];
elem getAns(int v, int l, int r, int a, int b) {
  if (l == a && r == b) return tr[v];
  int m = (l + r) / 2;
  if (b <= m) return getAns(lp[v], l, m, a, b);
  if (a > m) return getAns(rp[v], m + 1, r, a, b);
  elem el = getAns(lp[v], l, m, a, m), er = getAns(rp[v], m + 1, r, m + 1, b);
  return elem(max(max(el.ma, er.ma), el.ri + er.le),
              el.le + (el.le == m - l + 1 ? er.le : 0),
              er.ri + (er.ri == r - m ? el.ri : 0));
}
void addOne(int v, int pre, int l, int r, int a) {
  if (l == r) {
    tr[v] = elem(1, 1, 1);
    return;
  }
  int m = (l + r) / 2;
  if (a <= m) {
    lp[v] = sz++;
    rp[v] = rp[pre];
    addOne(lp[v], lp[pre], l, m, a);
  } else {
    lp[v] = lp[pre];
    rp[v] = sz++;
    addOne(rp[v], rp[pre], m + 1, r, a);
  }
  tr[v] =
      elem(max(max(tr[lp[v]].ma, tr[rp[v]].ma), tr[lp[v]].ri + tr[rp[v]].le),
           tr[lp[v]].le + (tr[lp[v]].le == m - l + 1 ? tr[rp[v]].le : 0),
           tr[rp[v]].ri + (tr[rp[v]].ri == r - m ? tr[lp[v]].ri : 0));
}
map<int, int> rt;
set<int> st;
int getRt(int he) { return rt[*st.lower_bound(he)]; }
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", &x[i].first), x[i].second = i;
  sort(x, x + n);
  reverse(x, x + n);
  int preRt = 0;
  for (int i = 0; i < n; i++) {
    int currt = sz++;
    addOne(currt, preRt, 0, n - 1, x[i].second);
    if (i == n - 1 || x[i].first != x[i + 1].first)
      rt[x[i].first] = currt, st.insert(x[i].first);
    preRt = currt;
  }
  int m;
  scanf("%d", &m);
  for (int i = 0; i < m; i++) {
    int l, r, w;
    scanf("%d%d%d", &l, &r, &w);
    l--, r--;
    int le = 1, ri = x[0].first;
    while (le + 1 < ri) {
      int mi = (le + ri) / 2;
      if (getAns(getRt(mi), 0, n - 1, l, r).ma >= w)
        le = mi;
      else
        ri = mi - 1;
    }
    while (le + 1 <= x[0].first &&
           getAns(getRt(le + 1), 0, n - 1, l, r).ma >= w)
      le++;
    printf("%d\n", le);
  }
  return 0;
}
