#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 5;
int n, q;
struct height {
  int h;
  int id;
} a[maxn];
int rt[maxn];
int u, v;
const int INF = 1e9 + 7;
struct tree {
  int l, r;
  int lc, rc;
  int suml, sumr, sum, len;
} tr[maxn * 25];
int cnt = 0;
void push_up(int now) {
  tr[now].len = tr[tr[now].lc].len + tr[tr[now].rc].len;
  tr[now].suml = tr[tr[now].lc].suml;
  if (tr[tr[now].lc].suml == tr[tr[now].lc].len)
    tr[now].suml += tr[tr[now].rc].suml;
  tr[now].sumr = tr[tr[now].rc].sumr;
  if (tr[tr[now].rc].sumr == tr[tr[now].rc].len)
    tr[now].sumr += tr[tr[now].lc].sumr;
  tr[now].sum = max(tr[tr[now].lc].sum, tr[tr[now].rc].sum);
  tr[now].sum = max(tr[now].sum, tr[tr[now].lc].sumr + tr[tr[now].rc].suml);
  return;
}
int build(int l, int r) {
  int now = ++cnt;
  tr[now].l = l;
  tr[now].r = r;
  if (l == r) {
    tr[now].suml = tr[now].sum = tr[now].sumr = 0;
    tr[now].len = 1;
    return now;
  }
  int mid = (l + r) >> 1;
  tr[now].lc = build(l, mid);
  tr[now].rc = build(mid + 1, r);
  push_up(now);
  return now;
}
int update(int last, int pos) {
  int now = ++cnt;
  tr[now] = tr[last];
  if (tr[now].l == pos && tr[now].r == pos) {
    tr[now].suml = tr[now].sumr = tr[now].sum = 1;
    tr[now].len = 1;
    return now;
  }
  int mid = (tr[now].l + tr[now].r) >> 1;
  if (pos <= mid)
    tr[now].lc = update(tr[last].lc, pos);
  else
    tr[now].rc = update(tr[last].rc, pos);
  push_up(now);
  return now;
}
int lt;
int query(int now, int l, int r) {
  int res = 0;
  if (tr[now].l >= l && tr[now].r <= r) {
    res = max(res, tr[now].sum);
    lt += tr[now].suml;
    res = max(res, lt);
    if (tr[now].suml != tr[now].len) {
      lt = tr[now].sumr;
      res = max(res, lt);
    }
    return res;
  }
  int mid = (tr[now].l + tr[now].r) >> 1;
  if (r <= mid)
    res = query(tr[now].lc, l, r);
  else if (l > mid)
    res = query(tr[now].rc, l, r);
  else {
    res = max(res, query(tr[now].lc, l, r));
    res = max(res, query(tr[now].rc, l, r));
  }
  return res;
}
bool cmp(height a, height b) {
  return (a.h > b.h || (a.h == b.h && a.id > b.id));
}
int k, l, r;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i].h;
    a[i].id = i;
  }
  sort(a + 1, a + n + 1, cmp);
  rt[0] = build(1, n);
  for (int i = 1; i <= n; ++i) {
    rt[i] = update(rt[i - 1], a[i].id);
  }
  cin >> q;
  while (q--) {
    cin >> u >> v >> k;
    l = 1, r = n;
    int ans = 0;
    while (l <= r) {
      int mid = (l + r) >> 1;
      lt = 0;
      if (query(rt[mid], u, v) >= k) {
        ans = mid;
        r = mid - 1;
      } else
        l = mid + 1;
    }
    cout << a[ans].h << "\n";
  }
  return 0;
}
