#include <bits/stdc++.h>
using namespace std;
struct arbNode {
  int left, right, best;
  bool isFull;
};
arbNode arb[(1 << 18)];
int n, A[100505], B[100505], r;
struct query {
  int l, r, w;
};
query H[100505];
int m, res[100505];
vector<int> G[100505], GG[100505];
int getIdx(int val) {
  int i, step;
  for (step = 1; step <= r; step <<= 1)
    ;
  for (i = 0; step; step >>= 1)
    if (i + step <= r && B[i + step] <= val) i += step;
  return i;
}
void normalize() {
  for (int i = 1; i <= n; i++) B[++r] = A[i];
  sort(B + 1, B + r + 1);
  int last = 1;
  for (int i = 2; i <= n; i++)
    if (B[i] != B[i - 1]) B[++last] = B[i];
  r = last;
  for (int i = 1; i <= n; i++) A[i] = getIdx(A[i]);
}
void update(int left, int right, int node, int pos) {
  if (left == right) {
    arb[node].left = arb[node].right = arb[node].best = arb[node].isFull = 1;
    return;
  }
  int mid = (left + right) >> 1;
  if (pos <= mid)
    update(left, mid, node * 2, pos);
  else
    update(mid + 1, right, node * 2 + 1, pos);
  arb[node].best = max(max(arb[node * 2].best, arb[node * 2 + 1].best),
                       arb[node * 2].right + arb[node * 2 + 1].left);
  arb[node].left = arb[node * 2].isFull
                       ? arb[node * 2].left + arb[node * 2 + 1].left
                       : arb[node * 2].left;
  arb[node].right = arb[node * 2 + 1].isFull
                        ? arb[node * 2 + 1].right + arb[node * 2].right
                        : arb[node * 2 + 1].right;
  arb[node].isFull = (arb[node].left == right - left + 1);
}
vector<int> vals;
void get(int left, int right, int node, int l, int r) {
  if (l > right || left > r) return;
  if (l <= left && right <= r) {
    vals.push_back(node);
    return;
  }
  int mid = (left + right) >> 1;
  get(left, mid, node * 2, l, r);
  get(mid + 1, right, node * 2 + 1, l, r);
}
int getBest(vector<int> &curr) {
  int last = 0, best = 0;
  for (size_t k = 0; k < curr.size(); k++) {
    best = max(best, arb[curr[k]].best);
    best = max(best, last + arb[curr[k]].left);
    last = arb[curr[k]].isFull ? last + arb[curr[k]].left : arb[curr[k]].right;
  }
  return best;
}
void cbin() {
  for (int i = 1; i <= m; i++) res[i] = 0;
  int step;
  for (step = 1; step <= r; step <<= 1)
    ;
  bool isOk[100505];
  for (; step; step >>= 1) {
    for (int i = 1; i <= m; i++) res[i] += step;
    memset(isOk, false, sizeof(isOk));
    for (int i = 1; i <= m; i++)
      if (res[i] <= r) GG[res[i]].push_back(i);
    for (int i = r; i >= 1; i--) {
      for (size_t j = 0; j < G[i].size(); j++) update(1, n, 1, G[i][j]);
      for (size_t j = 0; j < GG[i].size(); j++) {
        int curr = GG[i][j];
        vals.clear();
        get(1, n, 1, H[curr].l, H[curr].r);
        if (getBest(vals) >= H[curr].w) isOk[curr] = true;
      }
    }
    for (int i = 1; i <= m; i++)
      if (!isOk[i]) res[i] -= step;
    for (int i = 0; i <= r; i++) GG[i].clear();
    for (int i = 0; i < (1 << 18); i++) {
      arb[i].left = arb[i].right = arb[i].best = 0;
      arb[i].isFull = false;
    }
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &A[i]);
  normalize();
  for (int i = 1; i <= n; i++) G[A[i]].push_back(i);
  scanf("%d", &m);
  for (int i = 1; i <= m; i++) scanf("%d%d%d", &H[i].l, &H[i].r, &H[i].w);
  cbin();
  for (int i = 1; i <= m; i++) printf("%d\n", B[res[i]]);
  return 0;
}
