#include <bits/stdc++.h>
using namespace std;
constexpr long long pw(long long a, long long b, long long mod) {
  return (!b      ? 1
          : b & 1 ? a * pw(a * a % mod, b / 2, mod) % mod
                  : pw(a * a % mod, b / 2, mod));
}
constexpr long long N = 1e5 + 10;
constexpr long long MOD = 1e9 + 7;
constexpr long long INF = 1e18;
struct node {
  struct data {
    int ans, l, r, full;
    friend data merge(const data &a, const data &b) {
      data res;
      res.full = a.full & b.full;
      res.l = a.l + (a.full ? b.l : 0);
      res.r = b.r + (b.full ? a.r : 0);
      res.ans = max({a.ans, b.ans, a.r + b.l});
      return res;
    }
  };
  data d;
  node *lc, *rc;
  node() : d(), lc(this), rc(this) {}
  node *update(int l, int r, int ind) {
    node *cur = new node(*this);
    if (r - l == 1) {
      cur->d = {1, 1, 1, 1};
      return cur;
    }
    int mid = (l + r) >> 1;
    if (ind < mid)
      cur->lc = lc->update(l, mid, ind);
    else
      cur->rc = rc->update(mid, r, ind);
    cur->d = merge(cur->lc->d, cur->rc->d);
    return cur;
  }
  data get(int l, int r, int ql, int qr) {
    if (qr <= l || r <= ql) return {0, 0, 0, 1};
    if (ql <= l && r <= qr) return this->d;
    int mid = (l + r) >> 1;
    return merge(lc->get(l, mid, ql, qr), rc->get(mid, r, ql, qr));
  }
};
int n, q, H[N];
node *root[N];
vector<pair<int, int> > vec;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> H[i];
    vec.emplace_back(H[i], i);
  }
  sort(vec.begin(), vec.end());
  root[n] = new node();
  for (int i = n - 1; i >= 0; i--) {
    root[i] = root[i + 1]->update(0, n, vec[i].second);
  }
  cin >> q;
  while (q--) {
    int ql, qr, w;
    cin >> ql >> qr >> w;
    ql--;
    int l = 0, r = n;
    while (r - l > 1) {
      int mid = (l + r) >> 1;
      node::data cur = root[mid]->get(0, n, ql, qr);
      (cur.ans >= w ? l : r) = mid;
    }
    cout << vec[l].first << '\n';
  }
  return 0;
}
