#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5, SZ = 2e6 + 5;
struct node {
  int st, en, h, t, mx;
  inline node(int a = 0, int b = 0, int c = 0, int d = 0, int e = 0) {
    st = a;
    en = b;
    h = c;
    t = d;
    mx = e;
  }
  inline friend node merge(node a, node b) {
    if (a.st >= a.en) return b;
    if (b.st >= b.en) return a;
    node ans;
    ans.st = a.st;
    ans.en = b.en;
    ans.h = a.h + (a.h == a.en - a.st) * b.h;
    ans.t = b.t + (b.t == b.en - b.st) * a.t;
    ans.mx = max(max(a.mx, b.mx), a.t + b.h);
    return ans;
  }
} seg[SZ];
int n, m, NXT, h[N], p[N], root[N], L[SZ], R[SZ];
void build(int id = 0, int st = 0, int en = n) {
  seg[id] = node(st, en);
  if (en - st == 1) return;
  int mid = st + en >> 1;
  build(L[id] = ++NXT, st, mid);
  build(R[id] = ++NXT, mid, en);
}
int update(int p, int prv, int st = 0, int en = n) {
  int id = ++NXT;
  if (en - st == 1) {
    seg[id] = node(st, en, 1, 1, 1);
    return id;
  }
  L[id] = L[prv];
  R[id] = R[prv];
  int mid = st + en >> 1;
  if (p < mid)
    L[id] = update(p, L[id], st, mid);
  else
    R[id] = update(p, R[id], mid, en);
  seg[id] = merge(seg[L[id]], seg[R[id]]);
  return id;
}
node get(int l, int r, int id, int st = 0, int en = n) {
  if (r <= st || en <= l) return node();
  if (l <= st && en <= r) return seg[id];
  int mid = st + en >> 1;
  return merge(get(l, r, L[id], st, mid), get(l, r, R[id], mid, en));
}
inline bool cmp(int i, int j) { return h[i] > h[j]; }
inline void readInput() {
  cin >> n;
  for (int i = 0; i < n; i++) cin >> h[i];
}
inline void solve() {
  build();
  iota(p, p + n, 0);
  sort(p, p + n, cmp);
  for (int i = 0; i < n; i++) root[i + 1] = update(p[i], root[i]);
}
inline void writeOutput() {
  cin >> m;
  for (int i = 0; i < m; i++) {
    int l, r, w;
    cin >> l >> r >> w;
    int L = 0, R = n;
    while (L + 1 < R) {
      int mid = L + R >> 1;
      (get(l - 1, r, root[mid]).mx < w ? L : R) = mid;
    }
    cout << h[p[L]] << endl;
  }
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  readInput(), solve(), writeOutput();
  return 0;
}
