#include <bits/stdc++.h>
using namespace std;
int N, M;
int arr[132000];
struct ask {
  int l, r, w, tmp;
};
struct node {
  int lsum, rsum, max_sum;
} seg[132000 << 1];
int SZ;
inline node Merge(node lch, node rch, int l, int m, int r) {
  node ret;
  if (lch.max_sum == m - l + 1)
    ret.lsum = m - l + 1 + rch.lsum;
  else
    ret.lsum = lch.lsum;
  if (rch.max_sum == r - m)
    ret.rsum = r - m + lch.rsum;
  else
    ret.rsum = rch.rsum;
  ret.max_sum = max(ret.lsum, ret.rsum);
  ret.max_sum = max(lch.max_sum, rch.max_sum);
  ret.max_sum = max(ret.max_sum, lch.rsum + rch.lsum);
  return ret;
}
void modify(int l, int r, int pos, int p, int val) {
  if (l == r) {
    seg[p] = node{val, val, val};
  } else {
    int mid = (l + r) >> 1, lch = p << 1, rch = p << 1 | 1;
    if (pos <= mid)
      modify(l, mid, pos, lch, val);
    else
      modify(mid + 1, r, pos, rch, val);
    seg[p] = Merge(seg[lch], seg[rch], l, mid, r);
  }
}
node query(int l, int r, int ql, int qr, int p) {
  if (l == ql && r == qr)
    return seg[p];
  else {
    int mid = (l + r) >> 1, lch = p << 1, rch = p << 1 | 1;
    if (qr <= mid)
      return query(l, mid, ql, qr, lch);
    else if (ql > mid)
      return query(mid + 1, r, ql, qr, rch);
    else
      return Merge(query(l, mid, ql, mid, lch),
                   query(mid + 1, r, mid + 1, qr, rch), l, mid, r);
  }
}
void split(vector<int> ridx, vector<ask> que, vector<ask> &lque,
           vector<ask> &rque) {
  for (int now : ridx) modify(1, N, now, 1, 1);
  for (ask now : que) {
    int l = now.l, r = now.r, w = now.w;
    if (query(1, N, l, r, 1).max_sum >= w)
      rque.emplace_back(now);
    else
      lque.emplace_back(now);
  }
}
vector<int> h;
int ans[132000];
void divide(int l, int r, vector<int> &idx, vector<ask> &que) {
  if (l == r) {
    for (ask now : que) ans[now.tmp] = h[l];
    return;
  }
  int m = (l + r) >> 1;
  vector<int> lidx, ridx;
  for (int now : idx)
    if (arr[now] < h[m + 1])
      lidx.emplace_back(now);
    else
      ridx.emplace_back(now);
  vector<int>().swap(idx);
  vector<ask> lque, rque;
  split(ridx, que, lque, rque);
  vector<ask>().swap(que);
  divide(l, m, lidx, lque);
  for (int now : ridx) modify(1, N, now, 1, 0);
  divide(m + 1, r, ridx, rque);
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> N;
  vector<int> idx;
  for (int i = 1; i <= N; i++) {
    cin >> arr[i];
    h.emplace_back(arr[i]);
    idx.emplace_back(i);
  }
  sort(h.begin(), h.end());
  h.resize(unique(h.begin(), h.end()) - h.begin());
  vector<ask> que;
  cin >> M;
  for (int i = 0, l, r, w; i < M; i++) {
    cin >> l >> r >> w;
    que.emplace_back(ask{l, r, w, i});
  }
  SZ = (int)h.size() - 1;
  divide(0, SZ, idx, que);
  for (int i = 0; i < M; i++) cout << ans[i] << endl;
  return 0;
}
