#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC target("sse2")
#pragma GCC target("avx2")
using namespace std;
inline void opting() {
  ios_base::sync_with_stdio(false);
  cout.tie(0);
  cin.tie(0);
}
int inp() {
  int x;
  cin >> x;
  return x;
}
void make_unique(vector<int> &vec, bool sorted = false) {
  if (!sorted) sort((vec).begin(), (vec).end());
  vec.resize(unique((vec).begin(), (vec).end()) - vec.begin());
}
const int SQRT = 450, lg = 18 + 2, inlim = 2147483647;
const int maxn = 2e6 + 69, CL = 40, delta = 1e9 + 9, inf = 1e9 + 420;
int last[4 * maxn];
int n;
struct seg_node {
  int max_ones = 0;
  int pref = 0;
  int suff = 0;
  int sz = 0;
  int l_kid, r_kid;
} emp;
inline seg_node merge_nodes(const seg_node &A, const seg_node &B) {
  seg_node X;
  X.max_ones = max({A.max_ones, B.max_ones, A.suff + B.pref});
  X.sz = A.sz + B.sz;
  X.suff = B.suff;
  X.pref = A.pref;
  if (A.pref == A.sz) X.pref += B.pref;
  if (B.suff == B.sz) X.suff += A.suff;
  return X;
}
seg_node seg[4 * maxn];
int cur_node = 0;
pair<int, int> kid[maxn];
void show(seg_node A) {
  cout << A.max_ones << ' ' << A.pref << ' ' << A.suff << ' ' << A.sz << " <> "
       << endl;
}
void add_(int id, int idx, const int cheat, int L = 0, int R = n) {
  if (L <= idx and idx < R) {
    if (R - L == 1)
      seg[id].sz = seg[id].pref = seg[id].suff = seg[id].max_ones = 1;
    else {
      int mid = (L + R) >> 1;
      int lt = seg[cheat].l_kid;
      int rt = seg[cheat].r_kid;
      if (idx < mid) {
        lt = cur_node++;
        add_(lt, idx, seg[cheat].l_kid, L, mid);
      } else {
        rt = cur_node++;
        add_(rt, idx, seg[cheat].r_kid, mid, R);
      }
      seg[id] = merge_nodes(seg[lt], seg[rt]);
      seg[id].l_kid = lt;
      seg[id].r_kid = rt;
    }
  }
}
seg_node get_(int id, int l, int r, int L = 0, int R = n) {
  if (R <= l or r <= L) return emp;
  if (l <= L and R <= r) return seg[id];
  int mid = (L + R) >> 1;
  seg_node A = get_(seg[id].l_kid, l, r, L, mid);
  seg_node B = get_(seg[id].r_kid, l, r, mid, R);
  return merge_nodes(A, B);
}
int prime_set(int L = 0, int R = n) {
  int id = cur_node++;
  seg[id].sz = R - L;
  if (R == L + 1) return id;
  int mid = (L + R) >> 1;
  seg[id].l_kid = prime_set(L, mid);
  seg[id].r_kid = prime_set(mid, R);
  return id;
}
int starter[maxn];
inline bool check(int l, int r, int w, int H_key) {
  return get_(starter[H_key], l, r).max_ones >= w;
}
int bns(int l, int r, int w) {
  int st = 0;
  int en = n;
  while (en - st > 1) {
    int mid = (st + en) >> 1;
    if (check(l, r, w, mid))
      st = mid;
    else
      en = mid;
  }
  return st;
}
vector<pair<int, int> > v;
void input() {
  cin >> n;
  for (int i = 0; i < n; i++) v.push_back(make_pair(inp(), i));
}
void predo() {
  prime_set();
  sort((v).begin(), (v).end());
  int prev = 0;
  for (int i = n - 1; i > -1; i--) {
    starter[i] = cur_node++;
    add_(cur_node - 1, v[i].second, prev);
    prev = starter[i];
  }
}
void solve() {
  int m = inp();
  while (m--) {
    int l, r, w;
    cin >> l >> r >> w;
    l--;
    cout << v[bns(l, r, w)].first << ' ';
  }
}
int main() {
  opting();
  input();
  predo();
  solve();
}
