#include <bits/stdc++.h>
using namespace std;
class node {
 public:
  int l, suf, pre, mx;
  int left, right;
  node() { left = right = l = suf = pre = mx = 0; }
};
node St[60 * (int)(1e5 + 10)], bos;
pair<int, int> D[(int)(1e5 + 10)];
int R[(int)(1e5 + 10)], i, j, k, n, m, x, y, z, S = 1;
int A[(int)(1e5 + 10)], C[(int)(1e5 + 10)], B[(int)(1e5 + 10)],
    re[(int)(1e5 + 10)], a;
map<int, int> H;
int copy(int root) {
  int nroot = ++S;
  St[nroot] = St[root];
  return nroot;
}
node merge(node a, node b) {
  node c;
  c.pre = a.pre;
  if (a.pre == a.l) c.pre += b.pre;
  c.suf = b.suf;
  if (b.suf == b.l) c.suf += a.suf;
  c.mx = max(max(a.mx, b.mx), a.suf + b.pre);
  c.l = a.l + b.l;
  return c;
}
node que(int nroot, int bas, int son, int x, int y) {
  if (bas > y or son < x) return bos;
  if (x <= bas and son <= y) return St[nroot];
  return merge(que((St[nroot].left), bas, ((bas + son) >> 1), x, y),
               que((St[nroot].right), ((bas + son) >> 1) + 1, son, x, y));
}
int upd(int root, int bas, int son, int x) {
  if (bas > x or son < x) {
    return root;
  }
  int nroot = copy(root);
  if (bas == son) {
    St[nroot].l = St[nroot].suf = St[nroot].pre = St[nroot].mx = 1;
    return nroot;
  }
  int t1, t2;
  t1 = (St[nroot].left) = upd((St[nroot].left), bas, ((bas + son) >> 1), x);
  t2 = (St[nroot].right) =
      upd((St[nroot].right), ((bas + son) >> 1) + 1, son, x);
  St[nroot] = merge(St[(St[nroot].left)], St[(St[nroot].right)]);
  (St[nroot].left) = t1;
  (St[nroot].right) = t2;
  return nroot;
}
void init(int nroot, int bas, int son) {
  if (bas == son) {
    St[nroot].l = 1;
    return;
  }
  int t1, t2;
  t1 = (St[nroot].left) = ++S;
  init((St[nroot].left), bas, ((bas + son) >> 1));
  t2 = (St[nroot].right) = ++S;
  init((St[nroot].right), ((bas + son) >> 1) + 1, son);
  St[nroot] = merge(St[(St[nroot].left)], St[(St[nroot].right)]);
  (St[nroot].left) = t1;
  (St[nroot].right) = t2;
}
int main() {
  int q;
  cin >> n;
  for (i = 1; i <= n; i++) {
    scanf("%d", A + i);
    B[i] = A[i];
  }
  sort(B + 1, B + 1 + n);
  int s = 1;
  H[B[1]] = 1;
  re[1] = B[1];
  for (i = 2; i <= n; i++)
    if (B[i] != B[i - 1]) {
      H[B[i]] = ++s;
      re[s] = B[i];
    }
  for (i = 1; i <= n; i++) {
    D[i].first = H[A[i]];
    D[i].second = i;
  }
  sort(D + 1, D + 1 + n);
  R[0] = 1;
  init(1, 1, n);
  for (i = n; i >= 1; i--)
    R[D[i].first] = upd(R[D[i + 1].first], 1, n, D[i].second);
  cin >> q;
  for (i = 1; i <= q; i++) {
    scanf("%d %d %d", &x, &y, &a);
    int bas = 0;
    int son = s;
    while (bas < son) {
      int orta = bas + son >> 1;
      if (bas == orta) orta++;
      if (que(R[orta], 1, n, x, y).mx >= a)
        bas = orta;
      else
        son = orta - 1;
    }
    printf("%d\n", re[bas]);
  }
}
