#include <bits/stdc++.h>
using namespace std;
const long long mox = 1e5 + 9;
long long na[mox];
vector<pair<long long, long long> > ma;
struct sego {
  long long chap;
  long long rast;
  long long ans;
};
sego seg[25 * mox];
long long ba[25 * mox][2];
long long cnt;
vector<long long> rima;
void add(long long id, long long l, long long r, long long s, long long e) {
  if (l >= e || s >= r) {
    return;
  }
  if (l >= s && e >= r) {
    seg[id].ans = 1;
    seg[id].chap = 1;
    seg[id].rast = 1;
    return;
  }
  long long mid = (l + r) / 2;
  long long x = ba[id][0];
  long long y = ba[id][1];
  add(x, l, mid, s, e);
  add(y, mid, r, s, e);
  if (seg[x].ans == (mid - l)) {
    seg[id].chap = seg[x].ans + seg[y].chap;
  } else
    seg[id].chap = seg[x].chap;
  if (seg[y].ans == (r - mid)) {
    seg[id].rast = seg[y].ans + seg[x].rast;
  } else
    seg[id].rast = seg[y].rast;
  seg[id].ans = max(seg[x].ans, seg[y].ans);
  seg[id].ans = max(seg[id].ans, seg[x].rast + seg[y].chap);
}
long long bul(long long l, long long r) {
  if ((r - l == 1)) {
    return l;
  }
  long long o = cnt++;
  long long mid = (l + r) / 2;
  ba[o][0] = bul(l, mid);
  ba[o][1] = bul(mid, r);
  return o;
}
long long cheng(long long id, long long l, long long r, long long s,
                long long e) {
  if (l >= e || s >= r) {
    return id;
  }
  if (l >= s && e >= r) {
    return cnt++;
  }
  long long o = cnt++;
  long long mid = (l + r) / 2;
  ba[o][0] = cheng(ba[id][0], l, mid, s, e);
  ba[o][1] = cheng(ba[id][1], mid, r, s, e);
  return o;
}
sego p;
sego get(long long id, long long l, long long r, long long s, long long e) {
  if (l >= e || s >= r) {
    return p;
  }
  if (l >= s && e >= r) {
    return seg[id];
  }
  long long mid = (l + r) / 2;
  sego a = get(ba[id][0], l, mid, s, e);
  sego b = get(ba[id][1], mid, r, s, e);
  sego c;
  if (a.ans == (mid - l)) {
    c.chap = a.ans + b.chap;
  } else
    c.chap = a.chap;
  if (b.ans == (r - mid)) {
    c.rast = b.ans + a.rast;
  } else
    c.rast = b.rast;
  c.ans = max(a.ans, b.ans);
  c.ans = max(c.ans, a.rast + b.chap);
  return c;
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n;
  cin >> n;
  cnt = n;
  long long ri = bul(0, n);
  rima.push_back(ri);
  for (long long i = 0; i < n; i++) {
    cin >> na[i];
    ma.push_back({na[i], i});
  }
  sort(ma.begin(), ma.end());
  for (long long i = n - 1; i >= 0; i--) {
    ri = cheng(ri, 0, n, ma[i].second, ma[i].second + 1);
    add(ri, 0, n, ma[i].second, ma[i].second + 1);
    rima.push_back(ri);
  }
  long long m;
  cin >> m;
  while (m--) {
    long long l, r, w;
    cin >> l >> r >> w;
    long long low = -1;
    long long hi = n;
    while (low < hi - 1) {
      long long mid = (low + hi) / 2;
      if (get(rima[mid], 0, n, l - 1, r).ans >= w) {
        hi = mid;
      } else
        low = mid;
    }
    cout << ma[n - hi].first << '\n';
  }
}
