#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
const long double eps = 1e-7;
const int inf = 1000000010;
const long long INF = 10000000000000010LL;
const int mod = 1000000007;
const int MAXN = 100010, LOG = 30;
struct node {
  int ans, pref, suff, full;
  node(int x = 0) { ans = pref = suff = full = x; }
} seg[MAXN << 2];
node combine(node x, node y) {
  node out;
  out.ans = max(max(x.ans, y.ans), x.suff + y.pref);
  out.pref = x.pref;
  out.suff = y.suff;
  out.full = x.full & y.full;
  if (x.full) out.pref = x.pref + y.pref;
  if (y.full) out.suff = y.suff + x.suff;
  return out;
}
int n, m, k, u, v, x, y, t, cur;
int A[MAXN];
int ind[MAXN];
int query[MAXN];
long long l[MAXN], r[MAXN], w[MAXN];
long long dwn[MAXN], up[MAXN], mid[MAXN];
map<int, vector<int>> Q;
void build(int id, int tl, int tr) {
  if (tr - tl == 1) {
    seg[id] = node(0);
    return;
  }
  int mid = (tl + tr) >> 1;
  build(id << 1, tl, mid);
  build(id << 1 | 1, mid, tr);
  seg[id] = combine(seg[id << 1], seg[id << 1 | 1]);
}
void update(int id, int tl, int tr, int pos) {
  if (tr - tl == 1) {
    seg[id] = node(1);
    return;
  }
  int mid = (tl + tr) >> 1;
  if (pos < mid)
    update(id << 1, tl, mid, pos);
  else
    update(id << 1 | 1, mid, tr, pos);
  seg[id] = combine(seg[id << 1], seg[id << 1 | 1]);
}
node get(int id, int tl, int tr, int l, int r) {
  if (r <= tl || tr <= l) return node(0);
  if (l <= tl && tr <= r) return seg[id];
  int mid = (tl + tr) >> 1;
  return combine(get(id << 1, tl, mid, l, r), get(id << 1 | 1, mid, tr, l, r));
}
bool cmp(int i, int j) { return A[i] > A[j]; }
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> A[i];
  cin >> m;
  for (int i = 1; i <= m; i++) {
    cin >> l[i] >> r[i] >> w[i];
    up[i] = (1 << LOG);
  }
  for (int i = 1; i <= n; i++) ind[i] = i;
  sort(ind + 1, ind + n + 1, cmp);
  for (int __ = 0; __ < LOG; __++) {
    Q.clear();
    for (int i = 1; i <= m; i++) {
      query[i] = i;
      mid[i] = (dwn[i] + up[i]) >> 1;
      Q[-mid[i]].push_back(i);
    }
    build(1, 1, n + 1);
    int ptr = 1;
    for (auto it : Q) {
      int tmp = -it.first;
      while (ptr <= n && A[ind[ptr]] >= tmp) update(1, 1, n + 1, ind[ptr++]);
      for (int id : it.second) {
        if (get(1, 1, n + 1, l[id], r[id] + 1).ans >= w[id])
          dwn[id] = mid[id];
        else
          up[id] = mid[id];
      }
    }
  }
  for (int i = 1; i <= m; i++) cout << dwn[i] << '\n';
  return 0;
}
