#include <bits/stdc++.h>
using namespace std;
const int N = 1e5;
const long long LIM = 1e18;
const int INF = 0x3f3f3f3f;
const double eps = 1e-6;
const double PI = atan(1.0) * 4;
const int mod = 1e9 + 7;
int n, q, tot, root[N + 10];
struct Node {
  int val, idx;
} a[N + 10];
struct Tree {
  int l, r;
  int lc, rc, sum;
} tree[(N + 10) * 40];
void pushup(int x, int l, int r) {
  int mid = (l + r) / 2;
  tree[x].lc = tree[tree[x].l].lc;
  tree[x].rc = tree[tree[x].r].rc;
  tree[x].sum = max(tree[tree[x].l].sum, tree[tree[x].r].sum);
  if (tree[tree[x].l].lc == mid - l + 1) tree[x].lc += tree[tree[x].r].lc;
  if (tree[tree[x].r].rc == r - mid) tree[x].rc += tree[tree[x].l].rc;
  tree[x].sum = max(tree[x].sum, tree[tree[x].r].lc + tree[tree[x].l].rc);
}
void build(int& x, int l, int r) {
  x = ++tot;
  if (l == r) {
    tree[x].lc = tree[x].rc = tree[x].sum = 1;
    return;
  }
  int mid = (l + r) / 2;
  build(tree[x].l, l, mid);
  build(tree[x].r, mid + 1, r);
  pushup(x, l, r);
}
void update(int& x, int pre, int l, int r, int pos) {
  x = ++tot;
  tree[x] = tree[pre];
  if (l == r) {
    tree[x].lc = tree[x].rc = tree[x].sum = 0;
    return;
  }
  int mid = (l + r) / 2;
  if (pos <= mid)
    update(tree[x].l, tree[pre].l, l, mid, pos);
  else
    update(tree[x].r, tree[pre].r, mid + 1, r, pos);
  pushup(x, l, r);
}
Tree query(int x, int l, int r, int L, int R) {
  if (L <= l && r <= R) return tree[x];
  int mid = (l + r) / 2;
  if (R <= mid)
    return query(tree[x].l, l, mid, L, R);
  else if (L > mid)
    return query(tree[x].r, mid + 1, r, L, R);
  else {
    Tree ls = query(tree[x].l, l, mid, L, R),
         rs = query(tree[x].r, mid + 1, r, L, R);
    Tree c;
    c.lc = ls.lc, c.rc = rs.rc, c.sum = max(ls.sum, rs.sum);
    c.sum = max(c.sum, min(tree[tree[x].l].rc, mid - L + 1) +
                           min(tree[tree[x].r].lc, R - mid));
    return c;
  }
}
bool cmp(Node x, Node y) { return x.val < y.val; }
int main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  ;
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i].val, a[i].idx = i;
  sort(a + 1, a + 1 + n, cmp);
  build(root[0], 1, n);
  for (int i = 1; i <= n; i++) update(root[i], root[i - 1], 1, n, a[i].idx);
  cin >> q;
  while (q--) {
    int l, r, w;
    cin >> l >> r >> w;
    int L = 1, R = n, ans = 0;
    while (L <= R) {
      int mid = (L + R) / 2;
      if (query(root[mid - 1], 1, n, l, r).sum >= w)
        ans = mid, L = mid + 1;
      else
        R = mid - 1;
    }
    cout << a[ans].val << "\n";
  }
  return 0;
}
