#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 7;
struct node {
  int h, pos;
  int l, r, w;
  int id, op;
} p[N << 1], p1[N << 1], p2[N << 1];
int sorted[N];
int ans[N];
int n, m;
int L[N << 3], R[N << 3], M[N << 3];
inline void pushup(int k, int l, int r) {
  M[k] = max(R[k << 1] + L[(k << 1) | 1], max(M[k << 1], M[(k << 1) | 1]));
  int mid = (l + r) >> 1;
  if (L[k << 1] == mid - l + 1)
    L[k] = mid - l + 1 + L[(k << 1) | 1];
  else
    L[k] = L[k << 1];
  if (R[(k << 1) | 1] == r - mid)
    R[k] = r - mid + R[k << 1];
  else
    R[k] = R[(k << 1) | 1];
}
inline void update(int pos, int d, int k, int l, int r) {
  if (l == r) {
    L[k] = R[k] = M[k] = d;
    return;
  }
  int mid = (l + r) >> 1;
  if (pos <= mid)
    update(pos, d, k << 1, l, mid);
  else
    update(pos, d, (k << 1) | 1, mid + 1, r);
  pushup(k, l, r);
}
inline int query(int x, int y, int k, int l, int r) {
  if (x == l && y == r) return M[k];
  int mid = (l + r) >> 1;
  if (y <= mid)
    return query(x, y, k << 1, l, mid);
  else if (x > mid)
    return query(x, y, (k << 1) | 1, mid + 1, r);
  else {
    int ret = min(mid - x + 1, R[k << 1]) + min(y - mid, L[(k << 1) | 1]);
    return max(ret, max(query(x, mid, k << 1, l, mid),
                        query(mid + 1, y, (k << 1) | 1, mid + 1, r)));
  }
}
inline void slove(int x, int y, int l, int r) {
  if (x > y) return;
  if (l == r) {
    for (int i = x; i <= y; i++)
      if (p[i].op == 2) ans[p[i].id] = sorted[l];
    return;
  }
  int t1, t2;
  t1 = t2 = 0;
  int mid = (l + r) >> 1;
  for (int i = x; i <= y; i++) {
    if (p[i].op == 1) {
      if (p[i].h > mid) {
        update(p[i].pos, 1, 1, 1, n);
        p2[t2++] = p[i];
      } else
        p1[t1++] = p[i];
    } else {
      if (query(p[i].l, p[i].r, 1, 1, n) >= p[i].w)
        p2[t2++] = p[i];
      else
        p1[t1++] = p[i];
    }
  }
  memcpy(p + x, p1, t1 * sizeof(node));
  memcpy(p + x + t1, p2, t2 * sizeof(node));
  slove(x, x + t1 - 1, l, mid);
  for (int i = x + t1; i <= y; i++)
    if (p[i].op == 1) update(p[i].pos, 0, 1, 1, n);
  slove(x + t1, y, mid + 1, r);
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &p[i].h);
    p[i].pos = i;
    p[i].op = 1;
    sorted[i] = p[i].h;
  }
  sort(sorted + 1, sorted + n + 1);
  for (int i = 1; i <= n; i++)
    p[i].h = lower_bound(sorted + 1, sorted + n + 1, p[i].h) - sorted;
  scanf("%d", &m);
  for (int i = 1; i <= m; i++) {
    scanf("%d %d %d", &p[i + n].l, &p[i + n].r, &p[i + n].w);
    p[i + n].id = i;
    p[i + n].op = 2;
  }
  slove(1, n + m, 1, n);
  for (int i = 1; i <= m; i++) printf("%d\n", ans[i]);
  return 0;
}
