#include <bits/stdc++.h>
using namespace std;
const int N = 100100;
pair<int, int> re[N];
int lmx[N << 2], rmx[N << 2], mx[N << 2];
int x[N], y[N], z[N];
void pushup(int ind, int ll, int rr) {
  int mid = (ll + rr) >> 1;
  lmx[ind] = lmx[((ind) << 1)];
  if (lmx[((ind) << 1)] == mid - ll + 1) lmx[ind] += lmx[((ind) << 1 | 1)];
  rmx[ind] = rmx[((ind) << 1 | 1)];
  if (rmx[((ind) << 1 | 1)] == rr - mid) rmx[ind] += rmx[((ind) << 1)];
  mx[ind] = max(max(mx[((ind) << 1)], mx[((ind) << 1 | 1)]),
                rmx[((ind) << 1)] + lmx[((ind) << 1 | 1)]);
}
void update(int ind, int ll, int rr, int pos, int val) {
  if (ll == rr) {
    mx[ind] = lmx[ind] = rmx[ind] = val;
    return;
  }
  int mid = (ll + rr) >> 1;
  if (pos <= mid) {
    update(((ind) << 1), ll, mid, pos, val);
  } else {
    update(((ind) << 1 | 1), mid + 1, rr, pos, val);
  }
  pushup(ind, ll, rr);
}
struct Re {
  int lmx, rmx, mx;
  Re() {}
  Re(int lmx, int rmx, int mx) : lmx(lmx), rmx(rmx), mx(mx) {}
};
Re query(int ind, int ll, int rr, int l, int r) {
  if (ll == l && rr == r) {
    return Re(lmx[ind], rmx[ind], mx[ind]);
  }
  int mid = (ll + rr) >> 1;
  if (r <= mid) {
    return query(((ind) << 1), ll, mid, l, r);
  } else if (l > mid) {
    return query(((ind) << 1 | 1), mid + 1, rr, l, r);
  } else {
    Re retl = query(((ind) << 1), ll, mid, l, mid),
       retr = query(((ind) << 1 | 1), mid + 1, rr, mid + 1, r);
    Re ret;
    ret.lmx = retl.lmx;
    if (retl.lmx == mid - l + 1) ret.lmx += retr.lmx;
    ret.rmx = retr.rmx;
    if (retr.rmx == r - mid) ret.rmx += retl.rmx;
    ret.mx = max(max(retl.mx, retr.mx), retl.rmx + retr.lmx);
    return ret;
  }
}
int ans[N];
int n;
void solve(vector<int> v, int l, int r) {
  if (l == r) {
    for (int i = 0; i < v.size(); i++) {
      ans[v[i]] = re[l].first;
    }
    return;
  }
  int mid = (l + r) >> 1;
  for (int i = l; i <= mid; i++) update(1, 1, n, re[i].second, 1);
  vector<int> vl, vr;
  for (int i = 0; i < v.size(); i++) {
    int ret = query(1, 1, n, x[v[i]], y[v[i]]).mx;
    if (ret >= z[v[i]]) {
      vl.push_back(v[i]);
    } else {
      vr.push_back(v[i]);
    }
  }
  solve(vr, mid + 1, r);
  for (int i = l; i <= mid; i++) update(1, 1, n, re[i].second, 0);
  solve(vl, l, mid);
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &re[i].first);
    re[i].second = i;
  }
  sort(re + 1, re + n + 1, greater<pair<int, int> >());
  vector<int> v;
  int q;
  scanf("%d", &q);
  for (int i = 0; i < q; i++) {
    scanf("%d%d%d", &x[i], &y[i], &z[i]);
    v.push_back(i);
  }
  solve(v, 1, n);
  for (int i = 0; i < q; i++) {
    printf("%d\n", ans[i]);
  }
  return 0;
}
