#include <bits/stdc++.h>
int N, Q, a[100001], p[100001], cur = 1, O[100001];
struct node {
  int l, m, r, full;
} T[262144];
inline node single(int x) { return {x, x, x, x}; }
inline node operator+(const node &a, const node &b) {
  if (a.full && b.full) return {a.l + b.l, a.m + b.m, a.r + b.r, 1};
  if (a.full) return {a.l + b.l, std::max(a.l + b.l, b.m), b.r, 0};
  if (b.full) return {a.l, std::max(a.m, a.r + b.r), a.r + b.r, 0};
  return {a.l, std::max(std::max(a.m, b.m), a.r + b.l), b.r, 0};
}
void P(int x, int w) {
  int p = 1, l = 1, r = N;
  while (l < r) {
    int m = l + r >> 1;
    if (x <= m)
      p <<= 1, r = m;
    else
      p = p << 1 | 1, l = m + 1;
  }
  T[p] = single(w);
  while (p >>= 1) T[p] = T[p << 1] + T[p << 1 | 1];
}
node G(int p, int l, int r, int L, int R) {
  if (L <= l && r <= R) return T[p];
  int m = l + r >> 1;
  if (R <= m) return G(p << 1, l, m, L, R);
  if (L > m) return G(p << 1 | 1, m + 1, r, L, R);
  return G(p << 1, l, m, L, R) + G(p << 1 | 1, m + 1, r, L, R);
}
void build(int p, int l, int r) {
  if (l == r) {
    T[p] = single(1);
    return;
  }
  int m = l + r >> 1;
  build(p << 1, l, m);
  build(p << 1 | 1, m + 1, r);
  T[p] = T[p << 1] + T[p << 1 | 1];
}
void move(int x) {
  while (cur < x) P(p[cur++], 0);
  while (cur > x) P(p[--cur], 1);
}
struct query {
  int l, r, w, id;
} q[100001], tq[100001];
void Yvonne(int l, int r, int L, int R) {
  if (L > R) return;
  if (l == r) {
    for (int i = L; i <= R; i++) O[q[i].id] = a[p[l]];
    return;
  }
  int m = l + r + 1 >> 1;
  move(m);
  int curL = L - 1, curR = R + 1;
  for (int i = L; i <= R; i++)
    if (G(1, 1, N, q[i].l, q[i].r).m >= q[i].w)
      tq[--curR] = q[i];
    else
      tq[++curL] = q[i];
  for (int i = L; i <= R; i++) q[i] = tq[i];
  Yvonne(l, m - 1, L, curL);
  Yvonne(m, r, curR, R);
}
int main() {
  scanf("%d", &N);
  for (int i = 1; i <= N; i++) {
    scanf("%d", a + i);
    p[i] = i;
  }
  std::sort(p + 1, p + N + 1, [](int x, int y) { return a[x] < a[y]; });
  build(1, 1, N);
  scanf("%d", &Q);
  for (int i = 1; i <= Q; i++) {
    scanf("%d%d%d", &q[i].l, &q[i].r, &q[i].w);
    q[i].id = i;
  }
  Yvonne(1, N, 1, Q);
  for (int i = 1; i <= Q; i++) printf("%d\n", O[i]);
  return 0;
}
