#include <bits/stdc++.h>
using namespace std;
int n, m, num = 0, root[100005];
pair<int, int> h[100005];
struct node {
  int best, lef, rig, num;
  node() { best = lef = rig = num = 0; }
  node(int dot, int _num) {
    best = lef = rig = dot;
    num = _num;
  }
};
node better(node a, node b) {
  node re;
  re.num = a.num + b.num;
  if (a.lef == a.num)
    re.lef = a.lef + b.lef;
  else
    re.lef = a.lef;
  if (b.rig == b.num)
    re.rig = a.rig + b.rig;
  else
    re.rig = b.rig;
  re.best = max(max(a.best, b.best), a.rig + b.lef);
  return re;
}
struct persistentTree {
  node tree[100005 * 30];
  int lc[100005 * 30], rc[100005 * 30];
  int build(int l, int r) {
    int re = ++num;
    tree[re].num = r - l + 1;
    if (l == r) return re;
    int g = ((l + r) >> 1);
    lc[re] = build(l, g);
    rc[re] = build(g + 1, r);
    return re;
  }
  int update(int l, int r, int id, int x) {
    if (l == r) {
      tree[++num] = node(1, 1);
      return num;
    }
    int g = ((l + r) >> 1);
    int re = ++num;
    if (x <= g) {
      lc[re] = update(l, g, lc[id], x);
      rc[re] = rc[id];
    } else {
      lc[re] = lc[id];
      rc[re] = update(g + 1, r, rc[id], x);
    }
    tree[re] = better(tree[lc[re]], tree[rc[re]]);
    return re;
  }
  node get(int l, int r, int id, int x, int y) {
    if (l > y || r < x) return node(0, r - l + 1);
    if (x <= l && r <= y) return tree[id];
    int g = ((l + r) >> 1);
    node a = get(l, g, lc[id], x, y);
    node b = get(g + 1, r, rc[id], x, y);
    return better(a, b);
  }
} t;
void setup() {
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> h[i].first, h[i].second = i;
  sort(h + 1, h + n + 1);
  cin >> m;
}
void xuly() {
  root[n + 1] = t.build(1, n);
  for (int i = n; i >= 1; i--)
    root[i] = t.update(1, n, root[i + 1], h[i].second);
  int l, r, w;
  for (int i = 1; i <= m; i++) {
    cin >> l >> r >> w;
    int lef = 1, rig = n + 1;
    while (rig - lef > 1) {
      int g = ((rig + lef) >> 1);
      if (t.get(1, n, root[g], l, r).best >= w)
        lef = g;
      else
        rig = g;
    }
    cout << h[lef].first << '\n';
  }
}
int main() {
  iostream::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  setup();
  xuly();
  return 0;
}
