#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
struct gans {
  long long lp, rp, p;
};
gans seg[400005];
gans merge(gans x, gans y, long long xlen, long long ylen) {
  gans temp;
  if (x.lp == xlen) {
    temp.lp = x.p + y.lp;
  } else {
    temp.lp = x.lp;
  }
  if (y.rp == ylen) {
    temp.rp = y.p + x.rp;
  } else {
    temp.rp = y.rp;
  }
  temp.p = max(max(x.p, y.p), x.rp + y.lp);
  return temp;
}
void build(long long l, long long r, long long index) {
  if (l == r) {
    seg[index].lp = seg[index].rp = seg[index].p = 1;
    return;
  }
  long long mid = (l + r) / 2;
  build(l, mid, 2 * index);
  build(mid + 1, r, 2 * index + 1);
  seg[index] = merge(seg[2 * index], seg[2 * index + 1], mid - l + 1, r - mid);
}
void flip(long long pos, long long l, long long r, long long index) {
  if (l == r) {
    seg[index].lp = seg[index].rp = seg[index].p = 0;
    return;
  }
  long long mid = (l + r) / 2;
  if (pos <= mid) {
    flip(pos, l, mid, 2 * index);
  } else {
    flip(pos, mid + 1, r, 2 * index + 1);
  }
  seg[index] = merge(seg[2 * index], seg[2 * index + 1], mid - l + 1, r - mid);
}
gans query(long long x, long long y, long long l, long long r,
           long long index) {
  if (l > y || r < x) {
    gans temp;
    temp.lp = temp.rp = temp.p = 0;
    return temp;
  }
  if (l >= x && r <= y) {
    return seg[index];
  }
  long long mid = (l + r) / 2;
  return merge(query(x, y, l, mid, 2 * index),
               query(x, y, mid + 1, r, 2 * index + 1), mid - l + 1, r - mid);
}
long long n, h[100005], m, lo[100005], hi[100005], l[100005], r[100005],
    w[100005], ans[100005];
vector<long long> comp, v[100005], bin[100005];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (long long i = 1; i <= n; i++) {
    cin >> h[i];
    comp.push_back(h[i]);
  }
  sort(comp.begin(), comp.end());
  comp.erase(unique(comp.begin(), comp.end()), comp.end());
  for (long long i = 1; i <= n; i++) {
    long long temp = upper_bound(comp.begin(), comp.end(), h[i]) - comp.begin();
    v[temp].push_back(i);
  }
  cin >> m;
  long long top = comp.size();
  for (long long i = 1; i <= m; i++) {
    long long le, rr, ww;
    cin >> le >> rr >> ww;
    lo[i] = 1;
    hi[i] = top;
    l[i] = le;
    r[i] = rr;
    w[i] = ww;
    bin[(lo[i] + hi[i]) / 2].push_back(i);
  }
  while (1) {
    build(1, n, 1);
    bool lanjoot = 0;
    for (long long i = 1; i <= top; i++) {
      if (!bin[i].empty()) {
        lanjoot = 1;
      }
      while (!bin[i].empty()) {
        long long j = bin[i].back();
        bin[i].pop_back();
        if (query(l[j], r[j], 1, n, 1).p < w[j]) {
          hi[j] = i - 1;
        } else {
          lo[j] = i + 1;
        }
        if (lo[j] == hi[j] + 1) {
          ans[j] = hi[j];
        } else {
          bin[(lo[j] + hi[j]) / 2].push_back(j);
        }
      }
      for (long long j : v[i]) {
        flip(j, 1, n, 1);
      }
    }
    if (!lanjoot) break;
  }
  for (long long i = 1; i <= m; i++) {
    cout << comp[ans[i] - 1] << '\n';
  }
}
