#include <bits/stdc++.h>
using namespace std;
template <class T>
inline void umax(T &a, T b) {
  if (a < b) a = b;
}
template <class T>
inline void umin(T &a, T b) {
  if (a > b) a = b;
}
template <class T>
inline T abs(T a) {
  return a > 0 ? a : -a;
}
template <class T>
inline T gcd(T a, T b) {
  return __gcd(a, b);
}
template <class T>
inline T lcm(T a, T b) {
  return a / gcd(a, b) * b;
}
const int inf = 1e9 + 143;
const long long longinf = 1e18 + 143;
inline int read() {
  int x;
  scanf(" %d", &x);
  return x;
}
const int N = 1 << 17;
pair<int, int> a[N];
int l[N], r[N], w[N];
int bsl[N], bsr[N];
struct info {
  int L, R, G, sz;
};
info tree[N << 1];
info operator+(const info &a, const info &b) {
  info res;
  res.sz = a.sz + b.sz;
  res.G = max(a.G, max(b.G, a.R + b.L));
  res.L = a.L;
  if (a.sz == a.G) res.L = a.sz + b.L;
  res.R = b.R;
  if (b.sz == b.G) res.R = b.sz + a.R;
  return res;
}
void init() {
  for (int i = 0; i < N + N; i++) tree[i] = (info){0, 0, 0, 1};
}
void add(int x) {
  tree[x += N - 1] = (info){1, 1, 1, 1};
  while (x > 1) {
    x >>= 1;
    tree[x] = tree[x + x] + tree[x + x + 1];
  }
}
info get(int x, int l, int r, int x1, int x2) {
  if (l > x2 || r < x1) return (info){0, 0, 0, 1};
  if (l >= x1 && r <= x2) return tree[x];
  int m = (l + r) >> 1;
  return get(x + x, l, m, x1, x2) + get(x + x + 1, m + 1, r, x1, x2);
}
int main() {
  int n = read();
  vector<int> xs;
  for (int i = 1; i <= n; i++) {
    a[i].first = read();
    a[i].second = i;
    xs.push_back(a[i].first);
  }
  sort(a + 1, a + 1 + n);
  sort((xs).begin(), (xs).end());
  xs.erase(unique((xs).begin(), (xs).end()), xs.end());
  int m = read();
  for (int i = 0; i < m; i++) {
    l[i] = read();
    r[i] = read();
    w[i] = read();
    bsl[i] = 0;
    bsr[i] = (int)xs.size();
  }
  for (int it = 0; it < 17; it++) {
    vector<pair<int, int> > qs;
    for (int i = 0; i < m; i++) {
      if (bsl[i] + 1 < bsr[i])
        qs.push_back(make_pair((bsl[i] + bsr[i]) >> 1, i));
    }
    sort((qs).begin(), (qs).end());
    init();
    int ptr = n;
    for (int i = qs.size() - 1; i >= 0; i--) {
      int mid = qs[i].first;
      int id = qs[i].second;
      while (ptr > 0 && a[ptr].first >= xs[mid]) {
        add(a[ptr].second);
        --ptr;
      }
      0;
      if (get(1, 1, N, l[id], r[id]).G >= w[id]) {
        bsl[id] = mid;
      } else {
        bsr[id] = mid;
      }
    }
  }
  for (int i = 0; i < m; i++) {
    printf("%d\n", xs[bsl[i]]);
  }
  return 0;
}
