#include <bits/stdc++.h>
using namespace std;
const int maxn = 100005;
int n, m;
struct data {
  int h, id;
  bool operator<(const data &a) const { return h > a.h; }
} d[maxn];
int sz = 1, root[maxn];
struct node {
  int lc, rc, l, r, L, R, sum;
  node() {}
  node(int lc, int rc, int l, int r, int L, int R, int sum)
      : lc(lc), rc(rc), l(l), r(r), L(L), R(R), sum(sum) {}
  int getl() { return r - l + 1; }
} nod[maxn * 40];
void pushup(int u) {
  nod[u].L = nod[nod[u].lc].L +
             (nod[nod[u].lc].L == nod[nod[u].lc].getl() ? nod[nod[u].rc].L : 0);
  nod[u].R = nod[nod[u].rc].R +
             (nod[nod[u].rc].R == nod[nod[u].rc].getl() ? nod[nod[u].lc].R : 0);
  nod[u].sum = max(nod[nod[u].lc].R + nod[nod[u].rc].L,
                   max(nod[nod[u].lc].sum, nod[nod[u].rc].sum));
}
node merge(node a, node b) {
  node c;
  c.l = a.l;
  c.r = b.r;
  c.L = a.L + (a.L == a.getl() ? b.L : 0);
  c.R = b.R + (b.R == b.getl() ? a.R : 0);
  c.sum = max(a.R + b.L, max(a.sum, b.sum));
  return c;
}
void build(int &u, int l, int r) {
  if (u == 0) u = sz++;
  nod[u] = node(0, 0, l, r, 0, 0, 0);
  if (l == r) return;
  int mid = l + r >> 1;
  build(nod[u].lc, l, mid);
  build(nod[u].rc, mid + 1, r);
  pushup(u);
}
int insert(int u, int x) {
  int k = sz++;
  nod[k] = nod[u];
  if (nod[k].l == x && x == nod[k].r) {
    nod[k].sum = nod[k].L = nod[k].R = 1;
    return k;
  }
  int mid = nod[k].l + nod[k].r >> 1;
  if (x <= mid)
    nod[k].lc = insert(nod[k].lc, x);
  else
    nod[k].rc = insert(nod[k].rc, x);
  pushup(k);
  return k;
}
node query(int u, int l, int r) {
  if (l <= nod[u].l && nod[u].r <= r) {
    return nod[u];
  }
  int mid = nod[u].l + nod[u].r >> 1;
  if (r <= mid)
    return query(nod[u].lc, l, r);
  else if (l > mid)
    return query(nod[u].rc, l, r);
  else {
    node ll = query(nod[u].lc, l, r);
    node rr = query(nod[u].rc, l, r);
    return merge(ll, rr);
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &d[i].h);
    d[i].id = i;
  }
  sort(d + 1, d + 1 + n);
  build(root[0], 1, n);
  for (int i = 1; i <= n; i++) {
    root[i] = insert(root[i - 1], d[i].id);
  }
  scanf("%d", &m);
  int x, y, z, l, r, mid;
  for (int i = 1; i <= m; i++) {
    scanf("%d%d%d", &x, &y, &z);
    l = 0;
    r = n;
    while (l + 1 < r) {
      mid = l + r >> 1;
      if (query(root[mid], x, y).sum >= z)
        r = mid;
      else
        l = mid;
    }
    printf("%d\n", d[r].h);
  }
  return 0;
}
