#include <bits/stdc++.h>
using namespace std;
const int maxN = 100100;
struct segment {
  int pref, suff, sub, len;
  void init() {
    pref = 0;
    suff = 0;
    sub = 0;
  }
};
array<segment, 4 * maxN> seg;
array<int, maxN> L, R, W, l, r, mid;
array<vector<int>, maxN> imid;
vector<pair<int, int>> h;
int n, m;
segment merge(segment a, segment b) {
  segment ans;
  ans.pref = a.pref;
  ans.suff = b.suff;
  if (a.pref == a.len) {
    ans.pref += b.pref;
  }
  if (b.suff == b.len) {
    ans.suff += a.suff;
  }
  ans.sub = max(max(a.sub, b.sub), a.suff + b.pref);
  ans.len = a.len + b.len;
  return ans;
}
void init(int n, int l = 0, int r = maxN, int i = 1) {
  if (l >= n) {
    return;
  }
  if (l + 1 == r) {
    seg[i].init();
    seg[i].len = 1;
    return;
  }
  int mid = (l + r) / 2;
  init(n, l, mid, 2 * i);
  init(n, mid, r, 2 * i + 1);
  seg[i] = merge(seg[2 * i], seg[2 * i + 1]);
}
segment get(int L, int R, int l = 0, int r = maxN, int i = 1) {
  segment ans;
  if (r <= L or R <= l) {
    return ans;
  }
  if (L <= l and r <= R) {
    return seg[i];
  }
  int mid = (l + r) / 2;
  return merge(get(L, R, l, mid, 2 * i), get(L, R, mid, r, 2 * i + 1));
}
void add(int I, int l = 0, int r = maxN, int i = 1) {
  if (I < l or I >= r) {
    return;
  }
  if (l + 1 == r) {
    seg[i].sub = 1;
    seg[i].suff = 1;
    seg[i].pref = 1;
    return;
  }
  int mid = (l + r) / 2;
  add(I, l, mid, 2 * i);
  add(I, mid, r, 2 * i + 1);
  seg[i] = merge(seg[2 * i], seg[2 * i + 1]);
}
int32_t main() {
  scanf("%d", &n);
  for (int i = 0, hi; i < n; i++) {
    scanf("%d", &hi);
    h.emplace_back(hi, i);
  }
  sort(h.begin(), h.end());
  scanf("%d", &m);
  for (int i = 0; i < m; i++) {
    scanf("%d%d%d", &L[i], &R[i], &W[i]);
    L[i]--;
  }
  r.fill(n);
  bool done = false;
  while (not done) {
    done = true;
    init(n);
    imid.fill({});
    for (int i = 0; i < m; i++) {
      if (l[i] + 1 != r[i]) {
        done = false;
      }
      mid[i] = (l[i] + r[i]) / 2;
      imid[mid[i]].push_back(i);
    }
    for (int i = n - 1; i >= 0; i--) {
      add(h[i].second);
      for (int j : imid[i]) {
        if (l[j] + 1 == r[j]) {
          continue;
        }
        if (get(L[j], R[j]).sub >= W[j]) {
          l[j] = mid[j];
        } else {
          r[j] = mid[j];
        }
      }
    }
  }
  for (int i = 0; i < m; i++) {
    printf("%d\n", h[l[i]].first);
  }
}
