#include <bits/stdc++.h>
using namespace std;
const int M = 1e5 + 5, LG = 20, inf = 1e9, mod = 1e9 + 7;
int n;
int a[M];
int uba[M];
int ubs;
int q;
int fub(int x) { return lower_bound(uba, uba + ubs, x) - uba; }
vector<int> pss[M];
int ql[M], qr[M], qw[M], qlo[M], qhi[M], qba[M];
vector<int> qtp[M];
int seg[2 * M];
void upd(int p, int v) {
  seg[p + n] = v;
  for (p = (p + n) / 2; p > 0; p /= 2) {
    seg[p] = max(seg[2 * p], seg[2 * p + 1]);
  }
}
int get(int l, int r) {
  int res = -inf;
  for (l += n, r += n; l < r; l /= 2, r /= 2) {
    if (l & 1) res = max(res, seg[l++]);
    if (r & 1) res = max(res, seg[--r]);
  }
  return res;
}
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    scanf("%d", a + i);
    uba[i] = a[i];
  }
  sort(uba, uba + n);
  ubs = unique(uba, uba + n) - uba;
  for (int i = 0; i < n; i++) {
    a[i] = fub(a[i]);
    pss[a[i]].push_back(i);
  }
  cin >> q;
  for (int i = 0; i < q; i++) {
    scanf("%d%d%d", &ql[i], &qr[i], &qw[i]);
    ql[i]--;
    qlo[i] = 0;
    qhi[i] = ubs;
  }
  for (int rep = 0; rep < LG; rep++) {
    for (int i = 0; i < ubs; i++) {
      qtp[i].clear();
    }
    fill(seg, seg + 2 * n, -inf);
    set<int> se;
    for (int i = 0; i < q; i++) {
      if (qlo[i] + 1 == qhi[i]) continue;
      int mid = (qlo[i] + qhi[i]) >> 1;
      qtp[mid].push_back(i);
    }
    for (int i = 0; i < ubs; i++) {
      for (int x : qtp[i]) {
        auto ite = se.lower_bound(ql[x]);
        if (ite == se.end() || *ite >= qr[x]) {
          qba[x] = 1;
          continue;
        }
        int l = *ite;
        int res = l - ql[x];
        res = max(res, get(l + 1, qr[x]));
        ite = se.lower_bound(qr[x]);
        ite--;
        res = max(res, qr[x] - 1 - *ite);
        qba[x] = (res >= qw[x]);
      }
      for (int x : pss[i]) {
        auto ite = se.insert(x).first;
        if (ite == se.begin()) {
          upd(x, x);
          ite++;
          if (ite == se.end()) continue;
          upd(*ite, *ite - x - 1);
          continue;
        }
        ite--;
        upd(x, x - (*ite) - 1);
        ite++;
        ite++;
        if (ite == se.end()) continue;
        upd(*ite, *ite - x - 1);
      }
    }
    for (int i = 0; i < q; i++) {
      if (qlo[i] + 1 == qhi[i]) continue;
      int mid = (qlo[i] + qhi[i]) >> 1;
      if (qba[i])
        qlo[i] = mid;
      else
        qhi[i] = mid;
    }
  }
  for (int i = 0; i < q; i++) {
    cout << uba[qlo[i]] << '\n';
  }
}
