#include <bits/stdc++.h>
using namespace std;
const int NR = 1e5 + 10;
void Min(int& x, int y) { x = min(x, y); }
void Max(int& x, int y) { x = max(x, y); }
int n, m;
int all, tot;
int a[NR], p[NR], q[NR];
int num[NR];
int getid(int x) {
  int l = 1, r = all, ans = -1;
  while (l <= r) {
    int mid = (l + r >> 1);
    if (num[mid] <= x)
      ans = mid, l = mid + 1;
    else
      r = mid - 1;
  }
  return ans;
}
int to[NR], nxt[NR];
int head[NR];
int tt = 1;
void add(int x, int y) {
  to[tt] = y;
  nxt[tt] = head[x];
  head[x] = tt++;
}
int root[NR];
struct Nd {
  int l, r, le, ri, siz, sum;
} tr[NR << 5];
void update(int rt) {
  tr[rt].le = (tr[tr[rt].l].le == tr[tr[rt].l].siz)
                  ? tr[tr[rt].l].siz + tr[tr[rt].r].le
                  : tr[tr[rt].l].le;
  tr[rt].ri = (tr[tr[rt].r].ri == tr[tr[rt].r].siz)
                  ? tr[tr[rt].r].siz + tr[tr[rt].l].ri
                  : tr[tr[rt].r].ri;
  tr[rt].sum = max(tr[tr[rt].l].sum,
                   max(tr[tr[rt].r].sum, tr[tr[rt].l].ri + tr[tr[rt].r].le));
}
void build(int& rt, int l, int r) {
  rt = ++tot;
  if (l == r) {
    tr[rt].siz = 1;
    return;
  }
  int mid = (l + r >> 1);
  build(tr[rt].l, l, mid), build(tr[rt].r, mid + 1, r);
  tr[rt].siz = tr[tr[rt].l].siz + tr[tr[rt].r].siz;
}
void change(int& rt, int l, int r, int x) {
  int la = rt;
  rt = ++tot;
  tr[rt] = tr[la];
  if (l == r) {
    tr[rt].le = tr[rt].ri = tr[rt].sum = 1;
    return;
  }
  int mid = (l + r >> 1);
  if (x <= mid)
    change(tr[rt].l, l, mid, x);
  else
    change(tr[rt].r, mid + 1, r, x);
  update(rt);
}
Nd getnum(Nd a, Nd b) {
  Nd res;
  res.le = (a.le == a.siz) ? a.siz + b.le : a.le;
  res.ri = (b.ri == b.siz) ? b.siz + a.ri : b.ri;
  res.sum = max(a.sum, max(b.sum, a.ri + b.le));
  return res;
}
Nd query(int rt, int l, int r, int L, int R) {
  if (l == L && r == R) return tr[rt];
  int mid = (l + r >> 1);
  if (R <= mid)
    return query(tr[rt].l, l, mid, L, R);
  else if (L > mid)
    return query(tr[rt].r, mid + 1, r, L, R);
  else
    return getnum(query(tr[rt].l, l, mid, L, mid),
                  query(tr[rt].r, mid + 1, r, mid + 1, R));
}
int read() {
  int x = 0, f = 1;
  char ch = getchar();
  while (ch > '9' || ch < '0') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch <= '9' && ch >= '0') {
    x = (x << 3) + (x << 1) + (ch ^ 48);
    ch = getchar();
  }
  return x * f;
}
int main() {
  n = read();
  for (int i = 1; i <= n; i++) a[i] = read(), p[i] = a[i];
  sort(p + 1, p + n + 1);
  for (int i = 1; i <= n; i++) q[++all] = p[i];
  for (int i = 1; i <= all; i++) num[i] = q[i];
  build(root[all + 1], 1, n);
  for (int i = 1; i <= n; i++) add(getid(a[i]), i);
  for (int x = all; x >= 1; x--) {
    root[x] = root[x + 1];
    for (int i = head[x]; i; i = nxt[i]) {
      int y = to[i];
      change(root[x], 1, n, y);
    }
  }
  m = read();
  for (int i = 1; i <= m; i++) {
    int L = read(), R = read(), K = read();
    int l = 1, r = all, ans = 0;
    while (l <= r) {
      int mid = (l + r >> 1);
      if (query(root[mid], 1, n, L, R).sum >= K)
        ans = mid, l = mid + 1;
      else
        r = mid - 1;
    }
    printf("%d\n", num[ans]);
  }
  return 0;
}
