#include <bits/stdc++.h>
using namespace std;
const int N = 100000 + 77, L = 18;
int n, q, sz;
int a[N], Ql[N], Qr[N], Qw[N], Bl[N], Br[N], Bm[N];
vector<int> V, P[N], Q[N];
struct Node {
  int Pref = 0, Suff = 0, T = 0, l = 0, r = 0;
};
Node S[N << 2], Emp;
Node Merge(Node Tx, Node Ty) {
  Node res;
  res.l = Tx.l;
  res.r = Ty.r;
  res.T = max(Tx.T, Ty.T);
  res.Pref = Tx.Pref;
  res.Suff = Ty.Suff;
  if (res.Pref == Tx.r - Tx.l) res.Pref += Ty.Pref;
  if (res.Suff == Ty.r - Ty.l) res.Suff += Tx.Suff;
  res.T = max(res.T, Tx.Suff + Ty.Pref);
  return res;
}
inline int GetId(int x) {
  return lower_bound(V.begin(), V.end(), x) - V.begin() + 1;
}
void Build(int l = 1, int r = n + 1, int id = 1) {
  S[id].Pref = S[id].Suff = S[id].T = 0;
  S[id].l = l;
  S[id].r = r;
  if (r - l < 2) return;
  int mid = ((l + r) >> 1);
  Build(l, mid, id << 1);
  Build(mid, r, id << 1 ^ 1);
}
void Update(int x, int l = 1, int r = n + 1, int id = 1) {
  if (x < l || r <= x) return;
  if (r - l < 2) {
    S[id].Pref = S[id].Suff = S[id].T = 1;
    return;
  }
  int mid = ((l + r) >> 1);
  Update(x, l, mid, id << 1);
  Update(x, mid, r, id << 1 ^ 1);
  S[id] = Merge(S[id << 1], S[id << 1 ^ 1]);
}
Node Get(int ql, int qr, int l = 1, int r = n + 1, int id = 1) {
  if (qr <= l || r <= ql) return Emp;
  if (ql <= l && r <= qr) return S[id];
  int mid = ((l + r) >> 1);
  return Merge(Get(ql, qr, l, mid, id << 1), Get(ql, qr, mid, r, id << 1 ^ 1));
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  for (int i = 1; i <= n; ++i) cin >> a[i], V.push_back(a[i]);
  sort(V.begin(), V.end());
  V.resize(unique(V.begin(), V.end()) - V.begin());
  sz = V.size();
  for (int i = 1; i <= n; ++i) a[i] = GetId(a[i]), P[a[i]].push_back(i);
  cin >> q;
  for (int i = 1; i <= q; ++i) {
    cin >> Ql[i] >> Qr[i] >> Qw[i];
    Bl[i] = 1;
    Br[i] = sz + 1;
  }
  for (int t = 1; t < L; ++t) {
    for (int i = 0; i < sz + 1; ++i) Q[i].clear();
    for (int i = 1; i <= q; ++i) {
      Bm[i] = ((Br[i] + Bl[i]) >> 1);
      Q[Bm[i]].push_back(i);
    }
    Build();
    for (int i = sz; i > 0; --i) {
      for (auto x : P[i]) {
        Update(x);
      }
      for (auto id : Q[i]) {
        Node Ans = Get(Ql[id], Qr[id] + 1);
        if (Ans.T >= Qw[id])
          Bl[id] = Bm[id];
        else
          Br[id] = Bm[id];
      }
    }
  }
  for (int i = 1; i <= q; ++i) cout << V[Bl[i] - 1] << '\n';
  return 0;
}
