#include <bits/stdc++.h>
using namespace std;
struct fen {
  int h, id;
} f[100010];
struct tr {
  int l, r, ch[2], lest, rest, maxc;
  tr(int a = 0, int b = 0) {
    l = a;
    r = b;
    ch[0] = ch[1] = lest = rest = maxc = 0;
  }
} t[2000010];
int root[100010], tot;
void pushup(int x) {
  int mid = (t[x].l + t[x].r) >> 1;
  t[x].lest = t[t[x].ch[0]].lest +
              (t[t[x].ch[0]].lest == mid - t[x].l + 1 ? t[t[x].ch[1]].lest : 0);
  t[x].rest = t[t[x].ch[1]].rest +
              (t[t[x].ch[1]].rest == t[x].r - mid ? t[t[x].ch[0]].rest : 0);
  t[x].maxc = max(t[t[x].ch[0]].rest + t[t[x].ch[1]].lest,
                  max(t[t[x].ch[0]].maxc, t[t[x].ch[1]].maxc));
}
tr merge(tr a, tr b) {
  tr c;
  c.l = a.l;
  c.r = b.r;
  c.lest = a.lest + (a.lest == a.r - a.l + 1 ? b.lest : 0);
  c.rest = b.rest + (b.rest == b.r - b.l + 1 ? a.rest : 0);
  c.maxc = max(a.rest + b.lest, max(a.maxc, b.maxc));
  return c;
}
void insert(int pr, int& nr, int pos, int l, int r) {
  if (nr == 0) {
    tot++;
    nr = tot;
    t[nr].l = l;
    t[nr].r = r;
  }
  if (l == r) {
    t[nr].lest = t[nr].rest = t[nr].maxc = 1;
    return;
  }
  int mid = (l + r) >> 1;
  if (pos <= mid) {
    t[nr].ch[1] = t[pr].ch[1];
    insert(t[pr].ch[0], t[nr].ch[0], pos, l, mid);
  } else {
    t[nr].ch[0] = t[pr].ch[0];
    insert(t[pr].ch[1], t[nr].ch[1], pos, mid + 1, r);
  }
  pushup(nr);
}
tr query(int L, int R, int l, int r, int x) {
  if (L <= l && r <= R) {
    if (x)
      return t[x];
    else
      return tr(l, r);
  }
  int mid = (l + r) >> 1;
  if (R <= mid) return query(L, R, l, mid, t[x].ch[0]);
  if (L > mid) return query(L, R, mid + 1, r, t[x].ch[1]);
  return merge(query(L, R, l, mid, t[x].ch[0]),
               query(L, R, mid + 1, r, t[x].ch[1]));
}
bool cmp(fen a, fen b) { return a.h > b.h; }
int main() {
  int n, m, i, L, R, W, l, r, mid, ans;
  scanf("%d", &n);
  for (i = 1; i <= n; i++) {
    scanf("%d", &f[i].h);
    f[i].id = i;
  }
  sort(f + 1, f + n + 1, cmp);
  for (i = 1; i <= n; i++) insert(root[i - 1], root[i], f[i].id, 1, n);
  scanf("%d", &m);
  while (m--) {
    scanf("%d%d%d", &L, &R, &W);
    l = 1;
    r = n;
    while (l <= r) {
      mid = (l + r) >> 1;
      if (query(L, R, 1, n, root[mid]).maxc >= W) {
        ans = mid;
        r = mid - 1;
      } else
        l = mid + 1;
    }
    printf("%d\n", f[ans].h);
  }
}
