#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 7;
const int SEGN = 1e7 + 7;
struct data {
  int lef, rig, ans, len;
  data() {}
  data(int a, int b, int c, int d) : lef(a), rig(b), ans(c), len(d) {}
} seg[SEGN];
int n, sz, root[MAXN], L[SEGN], R[SEGN];
pair<int, int> h[MAXN];
void build(int x = 1, int xl = 0, int xr = n) {
  seg[x].len = xr - xl;
  if (xr - xl == 1) return;
  int xm = (xl + xr) >> 1;
  L[x] = x << 1;
  R[x] = x << 1 | 1;
  build(L[x], xl, xm);
  build(R[x], xm, xr);
}
data merge(data x, data y) {
  data res;
  res.lef = (x.lef == x.len ? x.lef + y.lef : x.lef);
  res.rig = (y.rig == y.len ? y.rig + x.rig : y.rig);
  res.ans = max(x.ans, max(y.ans, x.rig + y.lef));
  res.len = x.len + y.len;
  return res;
}
int upd(int idx, int x, int xl = 0, int xr = n) {
  if (idx < xl || idx >= xr) return x;
  int id = sz;
  sz++;
  if (xr - xl == 1) {
    seg[id].ans = seg[id].lef = seg[id].rig = seg[id].len = 1;
    return id;
  }
  int xm = (xl + xr) >> 1;
  L[id] = upd(idx, L[x], xl, xm);
  R[id] = upd(idx, R[x], xm, xr);
  seg[id] = merge(seg[L[id]], seg[R[id]]);
  return id;
}
data ask(int ql, int qr, int x, int xl = 0, int xr = n) {
  if (xr <= ql || xl >= qr) return data(0, 0, 0, 0);
  if (ql <= xl && qr >= xr) return seg[x];
  int xm = (xl + xr) >> 1;
  data a = ask(ql, qr, L[x], xl, xm);
  data b = ask(ql, qr, R[x], xm, xr);
  return merge(a, b);
}
int main() {
  scanf("%d", &n);
  root[0] = 1;
  seg[1].len = n;
  build();
  for (int i = 0; i < n; ++i) {
    scanf("%d", &h[i].first);
    h[i].second = i;
  }
  sort(h, h + n, greater<pair<int, int> >());
  sz = 4 * MAXN;
  for (int i = 0; i < n; ++i) root[i + 1] = upd(h[i].second, root[i]);
  int q;
  scanf("%d", &q);
  while (q--) {
    int l, r, w;
    scanf("%d %d %d", &l, &r, &w);
    l--;
    int lo = 0, hi = n;
    while (hi - lo > 1) {
      int mid = (lo + hi) >> 1;
      if (ask(l, r, root[mid]).ans >= w)
        hi = mid;
      else
        lo = mid;
    }
    printf("%d\n", h[hi - 1].first);
  }
  return 0;
}
