#include <bits/stdc++.h>
using namespace std;
const int maxn = (int)1e5 + 10;
;
struct node {
  int left, right, prf, suf, l, r, maxone;
} tree[20 * maxn];
int n, q, k, id, root[maxn];
pair<int, int> num[maxn];
int build(int l, int r) {
  int now = id++;
  tree[now].l = l;
  tree[now].r = r;
  tree[now].prf = 0;
  tree[now].suf = 0;
  tree[now].maxone = 0;
  if (l != r) {
    int mid = (l + r) / 2;
    tree[now].left = build(l, mid);
    tree[now].right = build(mid + 1, r);
  }
  return now;
}
node cmb(node a, node b) {
  node t;
  t.l = a.l;
  t.r = b.r;
  t.suf = (b.maxone == b.r - b.l + 1 ? b.maxone + a.suf : b.suf);
  t.prf = (a.maxone == a.r - a.l + 1 ? a.maxone + b.prf : a.prf);
  t.maxone =
      max(max(max(t.suf, t.prf), max(a.maxone, b.maxone)), a.suf + b.prf);
  return t;
}
int add(int l, int r, int perv, int pos) {
  int now = id++, mid = (l + r) / 2;
  int lchild, rchild;
  if (l == r) {
    tree[now].l = l;
    tree[now].r = r;
    tree[now].maxone = 1;
    tree[now].prf = 1;
    tree[now].suf = 1;
    return now;
  }
  if (pos <= mid) {
    lchild = add(l, mid, tree[perv].left, pos);
    rchild = tree[perv].right;
  } else {
    lchild = tree[perv].left;
    rchild = add(mid + 1, r, tree[perv].right, pos);
  }
  tree[now] = cmb(tree[lchild], tree[rchild]);
  tree[now].left = lchild;
  tree[now].right = rchild;
  return now;
}
node get(int v, int l, int r) {
  if (tree[v].l == l && tree[v].r == r) return tree[v];
  int mid = (tree[v].l + tree[v].r) / 2;
  if (r <= mid) return get(tree[v].left, l, r);
  if (l > mid) return get(tree[v].right, l, r);
  return cmb(get(tree[v].left, l, mid), get(tree[v].right, mid + 1, r));
}
int bsearch(int l, int r, int w) {
  int left = 0, right = n - 1, mid, ans = n - 1;
  node t;
  while (left <= right) {
    mid = (left + right) / 2;
    t = get(root[mid], l, r);
    if (t.maxone >= w) {
      right = mid - 1;
      ans = mid;
    } else {
      left = mid + 1;
    }
  }
  return ans;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> num[i].first;
    num[i].second = i;
  }
  sort(num, num + n, greater<pair<int, int> >());
  build(1, n);
  for (k = 0; k < n; k++) {
    root[k] = add(1, n, root[k - 1], num[k].second + 1);
  }
  cin >> q;
  while (q--) {
    int l, r, w;
    cin >> l >> r >> w;
    cout << num[bsearch(l, r, w)].first << endl;
  }
}
