#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
const int R = 25;
int n, q;
int h[N];
int ind[N];
int l[N];
int r[N];
int w[N];
int st[N];
int en[N];
vector<int> vec[N];
struct node {
  int ans, prefix, suffix;
  bool all;
  node(bool _all = false, int _ans = 0, int _prefix = 0, int _suffix = 0) {
    ans = _ans;
    prefix = _prefix;
    suffix = _suffix;
    all = _all;
  }
  friend node operator+(node a, node b) {
    node ans;
    ans.ans = max({a.ans, b.ans, a.suffix + b.prefix});
    if (a.all) {
      ans.prefix = b.prefix + a.prefix;
    } else {
      ans.prefix = a.prefix;
    }
    if (b.all) {
      ans.suffix = a.suffix + b.suffix;
    } else {
      ans.suffix = 0 + b.suffix;
    }
    ans.all = a.all & b.all;
    return ans;
  }
};
node seg[4 * N];
bool cmp(int i, int j) { return h[i] > h[j]; }
void build(int v = 1, int s = 0, int e = n) {
  if (e - s == 1) {
    seg[v] = node();
    return;
  }
  int mid = (e + s) / 2;
  int lc = 2 * v;
  int rc = lc + 1;
  build(lc, s, mid);
  build(rc, mid, e);
  seg[v] = seg[lc] + seg[rc];
}
void add(int ind, int v = 1, int s = 0, int e = n) {
  if (e - s == 1) {
    seg[v] = node(true, 1, 1, 1);
    return;
  }
  int mid = (e + s) / 2;
  int lc = 2 * v;
  int rc = lc + 1;
  if (ind < mid) {
    add(ind, lc, s, mid);
  } else {
    add(ind, rc, mid, e);
  }
  seg[v] = seg[lc] + seg[rc];
}
node get(int l, int r, int v = 1, int s = 0, int e = n) {
  if (r <= s || e <= l) {
    return node(true);
  }
  if (l <= s && e <= r) {
    return seg[v];
  }
  int mid = (e + s) / 2;
  int lc = 2 * v;
  int rc = lc + 1;
  return get(l, r, lc, s, mid) + get(l, r, rc, mid, e);
}
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> h[i];
  }
  for (int i = 1; i <= n; i++) {
    ind[i] = i - 1;
  }
  sort(ind + 1, ind + n + 1, cmp);
  cin >> q;
  for (int i = 0; i < q; i++) {
    cin >> l[i] >> r[i] >> w[i];
    l[i]--;
    en[i] = n;
  }
  for (int k = 0; k < R; k++) {
    build();
    for (int i = 0; i < q; i++) {
      if (en[i] - st[i] > 1) {
        int t = (st[i] + en[i]) / 2;
        vec[t].push_back(i);
      }
    }
    for (int i = 1; i <= n; i++) {
      add(ind[i]);
      for (auto j : vec[i]) {
        if (get(l[j], r[j]).ans >= w[j]) {
          en[j] = i;
        } else {
          st[j] = i;
        }
      }
      vec[i].clear();
    }
  }
  for (int i = 0; i < q; i++) {
    cout << h[ind[en[i]]] << endl;
  }
}
