#include <bits/stdc++.h>
using namespace std;
int read() {
  char ch = getchar();
  int h = 0, t = 1;
  while (ch != '-' && (ch > '9' || ch < '0')) ch = getchar();
  if (ch == '-') t = -1, ch = getchar();
  while (ch >= '0' && ch <= '9') {
    h = h * 10 + ch - '0';
    ch = getchar();
  }
  return h * t;
}
const int MAXN = 100100;
const int inf = 10000000;
int N, Q, Root[MAXN], node;
struct Poi {
  int val, pos;
} a[MAXN];
struct Seg {
  int lc, rc, lsum, rsum, sum, val;
} t[MAXN * 20];
int cmp(const Poi &A, const Poi &B) { return A.val < B.val; }
void Build(int &now, int l, int r) {
  t[++node] = t[now];
  now = node;
  t[now].lsum = t[now].rsum = t[now].sum = t[now].val = r - l + 1;
  if (l == r) return;
  int mid = (l + r) >> 1;
  Build(t[now].lc, l, mid);
  Build(t[now].rc, mid + 1, r);
}
Seg Merge(Seg B, Seg C) {
  Seg A;
  A.lsum = B.lsum;
  A.rsum = C.rsum;
  if (B.sum == B.val) A.lsum = max(A.lsum, B.sum + C.lsum);
  if (C.sum == C.val) A.rsum = max(A.rsum, C.sum + B.rsum);
  A.sum = max(B.rsum + C.lsum, max(B.sum, C.sum));
  A.val = B.val + C.val;
  return A;
}
void Add(int &now, int l, int r, int pos) {
  t[++node] = t[now];
  now = node;
  if (l == r) {
    t[now].lsum = t[now].rsum = t[now].sum = 0;
    t[now].val = -inf;
    return;
  }
  int mid = (l + r) >> 1;
  if (pos <= mid)
    Add(t[now].lc, l, mid, pos);
  else
    Add(t[now].rc, mid + 1, r, pos);
  Seg TT = Merge(t[t[now].lc], t[t[now].rc]);
  t[now].lsum = TT.lsum;
  t[now].rsum = TT.rsum;
  t[now].sum = TT.sum;
  t[now].val = TT.val;
}
Seg Query(int now, int l, int r, int gl, int gr) {
  if (l >= gl && r <= gr) return t[now];
  int mid = (l + r) >> 1;
  if (gr <= mid) return Query(t[now].lc, l, mid, gl, gr);
  if (gl >= mid + 1) return Query(t[now].rc, mid + 1, r, gl, gr);
  return Merge(Query(t[now].lc, l, mid, gl, gr),
               Query(t[now].rc, mid + 1, r, gl, gr));
}
int Check(int d, int l, int r, int k) {
  if (Query(Root[d], 1, N, l, r).sum >= k) return 1;
  return 0;
}
int main() {
  N = read();
  for (int i = 1; i <= N; i++) a[i].pos = i, a[i].val = read();
  Q = read();
  sort(a + 1, a + N + 1, cmp);
  Build(Root[0], 1, N);
  for (int i = 1; i <= N; i++) {
    Root[i] = Root[i - 1];
    if (a[i - 1].pos) Add(Root[i], 1, N, a[i - 1].pos);
  }
  for (int i = 1; i <= Q; i++) {
    int L = read(), R = read(), k = read();
    int l = 1, r = N, mid, ans;
    while (l <= r) {
      mid = (l + r) >> 1;
      if (Check(mid, L, R, k))
        l = mid + 1, ans = mid;
      else
        r = mid - 1;
    }
    printf("%d\n", a[ans].val);
  }
  return 0;
}
