#include <bits/stdc++.h>
using namespace std;
struct node {
  int l, r, mx, pre, suf;
};
vector<node> T;
vector<pair<int, int> > ht;
int n, m, a[100055], root[100055], first, second, z;
int init(int l, int r) {
  int ind = T.size();
  if (l == r) {
    T.push_back({-1, -1, 1, 1, 1});
    return ind;
  }
  int mid = (l + r) >> 1;
  T.push_back({-1, -1, r - l + 1, r - l + 1, r - l + 1});
  T[ind].l = init(l, mid);
  T[ind].r = init(mid + 1, r);
  return ind;
}
int update(int k, int l, int r, int tar) {
  int ind = T.size();
  if (l == r) {
    T.push_back({-1, -1, 0, 0, 0});
    return ind;
  }
  int mid = (l + r) >> 1, left, right;
  T.push_back({-1, -1, 0, 0, 0});
  if (tar <= mid) {
    left = update(T[k].l, l, mid, tar);
    right = T[k].r;
  } else if (tar > mid) {
    left = T[k].l;
    right = update(T[k].r, mid + 1, r, tar);
  }
  T[ind] = {left, right,
            max(max(T[left].mx, T[right].mx), T[left].suf + T[right].pre),
            T[left].pre, T[right].suf};
  if (T[left].pre == mid - l + 1) T[ind].pre = T[left].pre + T[right].pre;
  if (T[right].suf == r - mid) T[ind].suf = T[right].suf + T[left].suf;
  return ind;
}
node longest(int k, int l, int r, int tl, int tr) {
  if (tl <= l && r <= tr) {
    return T[k];
  }
  int mid = (l + r) >> 1;
  if (mid < tl) return longest(T[k].r, mid + 1, r, tl, tr);
  if (tr <= mid) return longest(T[k].l, l, mid, tl, tr);
  node rans = longest(T[k].r, mid + 1, r, mid + 1, tr);
  node lans = longest(T[k].l, l, mid, tl, mid);
  node ret = (node){0, 0, 0, 0, 0};
  ret.mx = max(max(rans.mx, lans.mx), lans.suf + rans.pre);
  ret.pre = lans.pre;
  if (lans.pre == mid - tl + 1) ret.pre = lans.pre + rans.pre;
  ret.suf = rans.suf;
  if (rans.suf == tr - mid) ret.suf = rans.suf + lans.suf;
  return ret;
}
int main() {
  T.reserve(1000000);
  scanf("%d", &n);
  ht.push_back({0, 0});
  for (int i = 1; i <= n; i++) {
    scanf("%d", a + i);
    ht.push_back({a[i], i});
  }
  sort(ht.begin(), ht.end());
  root[1] = init(1, n);
  for (int i = 2; i <= n; i++)
    root[i] = update(root[i - 1], 1, n, ht[i - 1].second);
  scanf("%d", &m);
  while (m--) {
    scanf("%d%d%d", &first, &second, &z);
    int l = 1, r = n + 1;
    while (l < r - 1) {
      int mid = (l + r) >> 1;
      node res = longest(root[mid], 1, n, first, second);
      if (res.mx >= z)
        l = mid;
      else
        r = mid;
    }
    printf("%d\n", ht[l]);
  }
  return 0;
}
