#include <bits/stdc++.h>
using namespace std;
int n, m, k;
const int MAXN = 200005;
const long long inf = 1e9;
struct segTree {
  struct Node {
    long long pre, suf, mx, sum;
    Node() {}
    Node(long long pre, long long suf, long long mx, long long sum) {
      this->pre = pre;
      this->suf = suf;
      this->mx = mx;
      this->sum = sum;
    }
  };
  vector<Node> tree;
  void init() {
    tree.clear();
    tree.resize(4 * n + 1, Node(-inf, -inf, -inf, -inf));
  }
  Node mrg(Node &L, Node &R) {
    Node ret = Node(-inf, -inf, -inf, -inf);
    ret.mx = max({L.mx, R.mx, L.suf + R.pre});
    ret.sum = L.sum + R.sum;
    ret.pre = max({L.pre, L.sum + R.pre});
    ret.suf = max({R.suf, R.sum + L.suf});
    return ret;
  }
  void update(int node, int st, int ed, int pos) {
    if (pos > ed || pos < st) return;
    if (st == ed) {
      tree[node] = Node(1, 1, 1, 1);
      return;
    }
    update(node * 2, st, (st + ed) / 2, pos);
    update(node * 2 + 1, (st + ed) / 2 + 1, ed, pos);
    tree[node] = mrg(tree[node * 2], tree[node * 2 + 1]);
  }
  Node query(int node, int st, int ed, int l, int r) {
    if (st > r || ed < l) return Node(-inf, -inf, -inf, -inf);
    if (st >= l && ed <= r) return tree[node];
    auto L = query(node * 2, st, (st + ed) / 2, l, r);
    auto R = query(node * 2 + 1, (st + ed) / 2 + 1, ed, l, r);
    return mrg(L, R);
  }
} seg;
int lo[MAXN], hi[MAXN], l[MAXN], r[MAXN], w[MAXN], h[MAXN];
vector<int> query[MAXN];
vector<pair<int, int> > bag;
int pbs() {
  seg.init();
  int update = 0;
  for (int i = 0; i < MAXN; i++) query[i].clear();
  for (int i = 1; i <= m; i++) {
    if (lo[i] <= hi[i]) {
      query[(lo[i] + hi[i]) / 2].push_back(i);
      update = 1;
    }
  }
  for (int i = (int)bag.size() - 1; i >= 0; i--) {
    seg.update(1, 1, n, bag[i].second);
    for (auto x : query[i]) {
      if (seg.query(1, 1, n, l[x], r[x]).mx >= w[x])
        lo[x] = i + 1;
      else
        hi[x] = i - 1;
    }
  }
  return update;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> h[i];
    bag.push_back({h[i], i});
  }
  sort(bag.begin(), bag.end());
  cin >> m;
  for (int i = 1; i <= m; i++) {
    cin >> l[i] >> r[i] >> w[i];
    lo[i] = 0;
    hi[i] = (int)bag.size() - 1;
  }
  while (pbs())
    ;
  for (int i = 1; i <= m; i++) {
    cout << bag[lo[i] - 1].first << "\n";
  }
  return 0;
}
