#include <bits/stdc++.h>
using namespace std;
int a[100005], rn[100005], tsz, rt[100005], rr[100005];
struct node {
  int first = 0, second = 0, pre = 0, suf = 0, mx = 0;
} sm[5000005], dull;
void sm_up(int xidx, int sidx, int l, int r, int first) {
  int mid = (l + r) / 2;
  if (l == r) {
    sm[xidx].pre = sm[xidx].suf = sm[xidx].mx = 1;
    return;
  }
  sm[xidx] = sm[sidx];
  if (first <= mid) {
    sm[xidx].first = ++tsz;
    sm_up(sm[xidx].first, sm[sidx].first, l, mid, first);
  } else {
    sm[xidx].second = ++tsz;
    sm_up(sm[xidx].second, sm[sidx].second, mid + 1, r, first);
  }
  node ls = sm[sm[xidx].first], rs = sm[sm[xidx].second];
  sm[xidx].pre = ls.pre + rs.pre * (ls.pre == mid + 1 - l);
  sm[xidx].suf = rs.suf + ls.suf * (rs.suf == r - mid);
  sm[xidx].mx = max(ls.mx, rs.mx);
  sm[xidx].mx = max(sm[xidx].mx, max(sm[xidx].pre, sm[xidx].suf));
  sm[xidx].mx = max(sm[xidx].mx, ls.suf + rs.pre);
}
node sm_get(int xidx, int l, int r, int first, int second) {
  int mid = (l + r) / 2;
  if (first > r || second < l) {
    return dull;
  }
  if (first <= l && r <= second) {
    return sm[xidx];
  }
  if (second <= mid) {
    return sm_get(sm[xidx].first, l, mid, first, second);
  } else if (first > mid) {
    return sm_get(sm[xidx].second, mid + 1, r, first, second);
  }
  node ls = sm_get(sm[xidx].first, l, mid, first, second),
       rs = sm_get(sm[xidx].second, mid + 1, r, first, second), res;
  res.pre = ls.pre + rs.pre * (ls.pre == mid + 1 - max(first, l));
  res.suf = rs.suf + ls.suf * (rs.suf == min(second, r) - mid);
  res.mx = max(ls.mx, rs.mx);
  res.mx = max(res.mx, max(res.pre, res.suf));
  res.mx = max(res.mx, ls.suf + rs.pre);
  return res;
}
int main() {
  int t, i, j, k, n, m, first, second, v, l, r, mid, b, mn;
  vector<pair<int, int>> sorter;
  scanf("%d", &n);
  for (i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
  }
  for (i = 1; i <= n; i++) {
    sorter.emplace_back(-a[i], i);
  }
  sort(sorter.begin(), sorter.end());
  for (i = 0; i < sorter.size(); i++) {
    rn[i + 1] = a[sorter[i].second];
    rt[i + 1] = ++tsz;
    sm_up(rt[i + 1], rt[i], 1, n, sorter[i].second);
  }
  scanf("%d", &t);
  while (t--) {
    scanf("%d %d %d", &first, &second, &v);
    l = 1;
    r = n;
    mn = n;
    while (l <= r) {
      mid = (l + r) / 2;
      node res = sm_get(rt[mid], 1, n, first, second);
      if (res.mx >= v) {
        mn = min(mn, mid);
        r = mid - 1;
      } else {
        l = mid + 1;
      }
    }
    printf("%d\n", rn[mn]);
  }
  return 0;
}
