#include <bits/stdc++.h>
using namespace std;
struct Block {
  int h, id;
} B[3001000];
typedef int arr[3001000];
arr L, R, Lx, Rx, Mx, Len, q, Rt, C;
int t, i, Q, n, tot, l, r, w, cnt;
inline int gi() {
  int ret = 0;
  char ch = getchar();
  while (ch > '9' || ch < '0') ch = getchar();
  while (ch <= '9' && ch >= '0') ret = ret * 10 + ch - '0', ch = getchar();
  return ret;
}
bool cmp(Block a, Block b) { return a.h < b.h; }
void Push(int x) {
  Mx[x] = max(Mx[L[x]], Mx[R[x]]);
  Lx[x] = Lx[L[x]], Rx[x] = Rx[R[x]];
  if (Lx[L[x]] == Len[L[x]]) Lx[x] += Lx[R[x]];
  if (Rx[R[x]] == Len[R[x]]) Rx[x] += Rx[L[x]];
  Mx[x] = max(Mx[x], max(Lx[x], Rx[x]));
  Mx[x] = max(Mx[x], Rx[L[x]] + Lx[R[x]]);
}
void Build(int &x, int l, int r) {
  x = ++cnt;
  if (l == r) {
    Len[x] = 1;
    return;
  }
  int mid = (l + r) >> 1;
  Build(L[x], l, mid);
  Build(R[x], mid + 1, r);
  Len[x] = Len[L[x]] + Len[R[x]];
}
void Ins(int &x, int y, int l, int r, int p, int v) {
  x = ++cnt;
  if (l == r) {
    Lx[x] = Rx[x] = Mx[x] = Len[x] = 1;
    return;
  }
  L[x] = L[y], R[x] = R[y];
  Len[x] = Len[y];
  Lx[x] = Lx[y], Rx[x] = Rx[y];
  int mid = (l + r) >> 1;
  if (p <= mid)
    Ins(L[x], L[y], l, mid, p, v);
  else
    Ins(R[x], R[y], mid + 1, r, p, v);
  Push(x);
}
void Query(int x, int l, int r, int xl, int xr) {
  if (l == xl && r == xr) {
    q[++t] = x;
    return;
  }
  int mid = (l + r) >> 1;
  if (xr <= mid)
    Query(L[x], l, mid, xl, xr);
  else if (xl > mid)
    Query(R[x], mid + 1, r, xl, xr);
  else
    Query(L[x], l, mid, xl, mid), Query(R[x], mid + 1, r, mid + 1, xr);
}
int Check(int l, int r, int x) {
  t = 0;
  int mx = 0;
  Query(Rt[x], 1, n, l, r);
  for (i = 1; i <= t; i++) mx = max(mx, Mx[q[i]]);
  int i = 1;
  while (i <= t) {
    int s = Rx[q[i]], j = i + 1;
    while (j <= t && Lx[q[j]] == Len[q[j]]) s += Len[q[j++]];
    if (j <= t) s += Lx[q[j]];
    mx = max(mx, s);
    i = j;
  }
  return mx;
}
void Work(int xl, int xr, int w) {
  int l = 1, r = tot, ans = 0;
  while (l <= r) {
    int mid = (l + r) >> 1;
    if (Check(xl, xr, mid) >= w)
      l = mid + 1, ans = mid;
    else
      r = mid - 1;
  }
  printf("%d\n", C[ans]);
}
bool sort(Block a, Block b) { return a.h < b.h; }
int main() {
  scanf("%d", &n);
  for (i = 1; i <= n; i++) scanf("%d", &B[i].h), B[i].id = i;
  sort(B + 1, B + n + 1, cmp);
  for (i = 1; i <= n; i++) {
    if (B[i].h != B[i - 1].h) ++tot;
    C[tot] = B[i].h;
    B[i].h = tot;
  }
  Build(Rt[tot + 1], 1, n);
  int j = n;
  for (i = tot; i >= 1; i--) {
    int la = Rt[i + 1];
    while (j && B[j].h >= i) {
      Ins(Rt[i], la, 1, n, B[j].id, 1), j--;
      la = Rt[i];
    }
    if (!Rt[i]) Rt[i] = Rt[i + 1];
  }
  scanf("%d", &Q);
  while (Q--) {
    int l = gi(), r = gi(), w = gi();
    Work(l, r, w);
  }
  return 0;
}
