#include <bits/stdc++.h>
using namespace std;
int n;
int st[600005], ans[100005], lz[600005];
int v[100005], v2[100005], m, q;
vector<pair<pair<int, int>, pair<int, int>>> qr;
void prop(int p, int L, int R) {
  if (lz[p]) {
    st[p] += lz[p];
    lz[2 * p] += lz[p];
    lz[2 * p + 1] += lz[p];
    lz[p] = 0;
  }
}
void upd(int p, int L, int R, int i, int j, int v) {
  prop(p, L, R);
  if (j < L || i > R) return;
  if (i <= L && R <= j) {
    lz[p] = v;
    prop(p, L, R);
    return;
  }
  int mid = (L + R) / 2;
  upd(2 * p, L, mid, i, j, v);
  upd(2 * p + 1, mid + 1, R, i, j, v);
  st[p] = max(st[2 * p], st[2 * p + 1]);
}
int qry(int p, int L, int R, int i, int j) {
  prop(p, L, R);
  if (j < L || i > R) return 0;
  if (i <= L && R <= j) return st[p];
  int mid = (L + R) / 2;
  return max(qry(2 * p, L, mid, i, j), qry(2 * p + 1, mid + 1, R, i, j));
}
void pbs() {
  vector<vector<pair<pair<int, int>, pair<int, int>>>> qrs;
  vector<pair<int, int>> meios;
  meios.push_back(make_pair(0, m - 1));
  qrs.push_back(qr);
  while (!meios.empty()) {
    vector<vector<pair<pair<int, int>, pair<int, int>>>> qrs2;
    vector<pair<int, int>> meios2;
    set<int> z;
    set<pair<int, int>> s;
    memset(st, 0, sizeof st);
    memset(lz, 0, sizeof lz);
    for (int i = 1; i <= n; i++) {
      upd(1, 1, n, i, i, n - i + 1);
      s.insert(make_pair(v[i - 1], i));
    }
    z.insert(0);
    for (int i = 0; i < meios.size(); i++) {
      if (meios[i].first > meios[i].second) continue;
      vector<pair<pair<int, int>, pair<int, int>>> mi, ma;
      int mid = (meios[i].first + meios[i].second) / 2, x = v2[mid];
      while (s.begin()->first < x) {
        int zid, id;
        id = s.begin()->second;
        set<int>::iterator it = z.lower_bound(id);
        it--;
        zid = *it;
        s.erase(s.begin());
        z.insert(id);
        upd(1, 1, n, zid + 1, id, -qry(1, 1, n, id, id));
      }
      for (int j = 0; j < qrs[i].size(); j++) {
        if (qry(1, 1, n, qrs[i][j].first.first,
                qrs[i][j].first.second - qrs[i][j].second.first + 1) >=
            qrs[i][j].second.first) {
          ans[qrs[i][j].second.second] = max(ans[qrs[i][j].second.second], x);
          ma.push_back(qrs[i][j]);
        } else
          mi.push_back(qrs[i][j]);
      }
      meios2.push_back(make_pair(meios[i].first, mid - 1));
      meios2.push_back(make_pair(mid + 1, meios[i].second));
      qrs2.push_back(mi);
      qrs2.push_back(ma);
    }
    meios = meios2;
    qrs = qrs2;
  }
}
int main() {
  set<int> s;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", v + i);
    s.insert(v[i]);
  }
  while (!s.empty()) {
    v2[m] = *s.begin();
    s.erase(s.begin());
    m++;
  }
  scanf("%d", &q);
  for (int i = 0; i < q; i++) {
    int l, r, z;
    scanf("%d %d %d", &l, &r, &z);
    qr.push_back(make_pair(make_pair(l, r), make_pair(z, i)));
  }
  pbs();
  for (int i = 0; i < q; i++) {
    printf("%d\n", ans[i]);
  }
  return 0;
}
