#include <bits/stdc++.h>
using namespace std;
constexpr long long pw(long long a, long long b, long long mod) {
  return (!b      ? 1
          : b & 1 ? a * pw(a * a % mod, b / 2, mod) % mod
                  : pw(a * a % mod, b / 2, mod));
}
constexpr long long N = 1e5 + 10;
constexpr long long LOG = 20;
constexpr long long T = 2 * N * LOG;
constexpr long long MOD = 1e9 + 7;
constexpr long long INF = 1e18;
struct node {
  int ans, l, r, full;
  friend node merge(const node &a, const node &b) {
    node res;
    res.full = a.full & b.full;
    res.l = a.l + (a.full ? b.l : 0);
    res.r = b.r + (b.full ? a.r : 0);
    res.ans = max({a.ans, b.ans, a.r + b.l});
    return res;
  }
} seg[T];
int L[T], R[T], ID;
int n, q, H[N], root[N];
vector<pair<int, int> > vec;
int Update(int id, int l, int r, int ind) {
  int cid = ++ID;
  if (r - l == 1) {
    seg[cid] = {1, 1, 1, 1};
    return cid;
  }
  int mid = (l + r) >> 1;
  L[cid] = L[id];
  R[cid] = R[id];
  if (ind < mid)
    L[cid] = Update(L[cid], l, mid, ind);
  else
    R[cid] = Update(R[cid], mid, r, ind);
  seg[cid] = merge(seg[L[cid]], seg[R[cid]]);
  return cid;
}
node Get(int id, int l, int r, int ql, int qr) {
  if (qr <= l || r <= ql) return {0, 0, 0, 1};
  if (ql <= l && r <= qr) return seg[id];
  int mid = (l + r) >> 1;
  return merge(Get(L[id], l, mid, ql, qr), Get(R[id], mid, r, ql, qr));
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> H[i];
    vec.emplace_back(H[i], i);
  }
  sort(vec.begin(), vec.end());
  for (int i = n - 1; i >= 0; i--) {
    root[i] = Update(root[i + 1], 0, n, vec[i].second);
  }
  cin >> q;
  while (q--) {
    int ql, qr, w;
    cin >> ql >> qr >> w;
    ql--;
    int l = 0, r = n;
    while (r - l > 1) {
      int mid = (l + r) >> 1;
      node cur = Get(root[mid], 0, n, ql, qr);
      (cur.ans >= w ? l : r) = mid;
    }
    cout << vec[l].first << '\n';
  }
  return 0;
}
