#include <bits/stdc++.h>
using namespace std;
struct Node {
  int l, r;
  Node() { l = r = 0; }
} tree[100005 * 20];
int totNode = 0;
struct data {
  int sum, pref, suff, ans;
  data() { sum = pref = suff = ans = 0; }
} ara[100005 * 20];
data mergedata(const data &a, const data &b, int l, int r) {
  data ret;
  int mid = (l + r) / 2;
  ret.sum = a.sum + b.sum;
  ret.pref = a.pref;
  if (a.sum == mid - l + 1) ret.pref = a.sum + b.pref;
  ret.suff = b.suff;
  if (b.sum == r - mid) ret.suff = b.sum + a.suff;
  ret.ans = max(a.ans, max(b.ans, a.suff + b.pref));
  return ret;
}
int update(int node, int b, int e, int i, int val) {
  int cur = ++totNode;
  int mid = (b + e) / 2;
  if (b == e) {
    ara[cur].sum = ara[cur].pref = ara[cur].suff = ara[cur].ans = 1;
    return cur;
  }
  if (i <= mid) {
    tree[cur].l = update(tree[node].l, b, mid, i, val);
    tree[cur].r = tree[node].r;
  } else {
    tree[cur].r = update(tree[node].r, mid + 1, e, i, val);
    tree[cur].l = tree[node].l;
  }
  ara[cur] = mergedata(ara[tree[cur].l], ara[tree[cur].r], b, e);
  return cur;
}
data query(int node, int b, int e, int i, int j) {
  if (j < b || e < i) return data();
  if (i <= b && e <= j) return ara[node];
  int lson = tree[node].l, rson = tree[node].r, mid = (b + e) / 2;
  return mergedata(query(lson, b, mid, i, j), query(rson, mid + 1, e, i, j), b,
                   e);
}
int main() {
  int n;
  scanf("%d", &n);
  pair<int, int> ara[n + 1];
  for (int i = 1; i <= n; i++) {
    scanf("%d", &ara[i].first);
    ara[i].second = i;
  }
  sort(ara + 1, ara + n + 1);
  reverse(ara + 1, ara + n + 1);
  int root[n + 1];
  root[0] = 0;
  for (int i = 1; i <= n; i++) {
    root[i] = update(root[i - 1], 1, n, ara[i].second, 1);
  }
  int q;
  scanf("%d", &q);
  while (q--) {
    int i, j, w;
    scanf("%d %d %d", &i, &j, &w);
    int l = 1, r = n;
    while (l <= r) {
      int mid = (l + r) / 2;
      data now = query(root[mid], 1, n, i, j);
      if (now.ans >= w)
        r = mid - 1;
      else
        l = mid + 1;
    }
    printf("%d\n", ara[r + 1].first);
  }
  return 0;
}
