#include <bits/stdc++.h>
using namespace std;
template <typename T, typename L>
bool smax(T& x, L y) {
  return x < y ? (x = y, true) : false;
}
template <typename T, typename L>
bool smin(T& x, L y) {
  return y < x ? (x = y, true) : false;
}
struct node {
  node *l, *r;
  int len, pref, suff, val;
  node() {
    l = NULL;
    r = NULL;
    len = pref = suff = val = 0;
  }
};
struct nnode {
  int len, pref, suff, val;
  nnode() { len = pref = suff = val = 0; }
  inline void modify(node* id) {
    len = id->len;
    pref = id->pref;
    suff = id->suff;
    val = id->val;
  }
};
inline void build_seg();
inline void build(node* id, int be, int en);
inline void add_to_seg(node* prev, node* cur, int be, int en, int p);
inline nnode query(node* id, int be, int en, int l, int r);
const int MAXN = 1e5 + 15;
node* version[MAXN];
int n, q;
bool b[MAXN];
pair<int, int> h[MAXN];
int main() {
  ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> h[i].first;
    h[i].second = i;
  }
  sort(h, h + n, [](pair<int, int> a, pair<int, int> b) { return b <= a; });
  build_seg();
  cin >> q;
  for (int i = 0, l, r, w; i < q; i++) {
    cin >> l >> r >> w;
    int lo, hi;
    lo = -1, hi = n - 1;
    while (lo + 1 < hi) {
      int mid = (lo + hi) >> 1;
      if (query(version[mid], 0, n, l - 1, r).val >= w) {
        hi = mid;
      } else {
        lo = mid;
      }
    }
    cout << h[hi].first << '\n';
  }
  return false;
}
inline void build_seg() {
  node* tree = new node();
  b[h[0].second] = true;
  build(tree, 0, n);
  version[0] = tree;
  for (int i = 1; i < n; i++) {
    b[h[i].second] = true;
    version[i] = new node();
    add_to_seg(version[i - 1], version[i], 0, n, h[i].second);
  }
}
inline void build(node* id, int be, int en) {
  if (be == en - 1) {
    id->len = 1;
    id->val = b[be];
    id->pref = b[be];
    id->suff = b[be];
    return;
  }
  int mid = (be + en) >> 1;
  id->l = new node();
  id->r = new node();
  build(id->l, be, mid);
  build(id->r, mid, en);
  id->val = max(id->l->val, max(id->r->val, id->l->suff + id->r->pref));
  id->pref = id->l->pref + (id->l->pref == id->l->len ? id->r->pref : 0);
  id->suff = id->r->suff + (id->r->suff == id->r->len ? id->l->suff : 0);
  id->len = id->l->len + id->r->len;
}
inline void add_to_seg(node* prev, node* cur, int be, int en, int p) {
  if (be == en - 1) {
    cur->val = b[be];
    cur->pref = cur->suff = b[be];
    cur->len = 1;
    return;
  }
  if (be > p || en <= p) return;
  int mid = (be + en) >> 1;
  if (p < mid) {
    cur->l = new node();
    cur->r = prev->r;
    add_to_seg(prev->l, cur->l, be, mid, p);
  } else {
    cur->r = new node();
    cur->l = prev->l;
    add_to_seg(prev->r, cur->r, mid, en, p);
  }
  cur->val = max(cur->l->val, max(cur->r->val, cur->l->suff + cur->r->pref));
  cur->pref = cur->l->pref + (cur->l->pref == cur->l->len ? cur->r->pref : 0);
  cur->suff = cur->r->suff + (cur->r->suff == cur->r->len ? cur->l->suff : 0);
  cur->len = cur->l->len + cur->r->len;
}
inline nnode query(node* id, int be, int en, int l, int r) {
  if (be >= r || en <= l) {
    nnode ret;
    ret.val = 0;
    ret.pref = 0;
    ret.suff = 0;
    ret.len = id->len;
    return ret;
  }
  if (be >= l && en <= r) {
    nnode ret;
    ret.modify(id);
    return ret;
  }
  int mid = (be + en) >> 1;
  nnode ret, rel;
  ret = query(id->l, be, mid, l, r);
  rel = query(id->r, mid, en, l, r);
  ret.val = max(ret.val, max(rel.val, ret.suff + rel.pref));
  ret.pref = ret.pref + (ret.pref == ret.len ? rel.pref : 0);
  ret.suff = rel.suff + (rel.suff == rel.len ? ret.suff : 0);
  ret.len = ret.len + rel.len;
  return ret;
}
