#include <bits/stdc++.h>
using std::cout;
using std::endl;
using std::max;
using std::sort;
using std::unique;
const int MAXN = 100000 + 5;
const int LOG = 20;
const int MAXT = LOG * MAXN;
namespace FST {
struct TNode {
  int len;
  int lenL;
  int lenR;
  int lenMax;
  int lson;
  int rson;
} tree[MAXT];
int nodeCnt = 0;
typedef TNode& ref;
void push(const ref l, const ref r, ref now) {
  now.len = l.len + r.len;
  now.lenMax = max(max(l.lenMax, r.lenMax), l.lenR + r.lenL);
  now.lenL = l.lenL + (l.lenL == l.len ? r.lenL : 0);
  now.lenR = r.lenR + (r.lenR == r.len ? l.lenR : 0);
}
void push(ref now) {
  int l = now.lson;
  int r = now.rson;
  push(tree[l], tree[r], now);
}
void init(int& now, int l, int r) {
  now = nodeCnt++;
  if (l == r) {
    tree[now].len = 1;
    tree[now].lenL = 0;
    tree[now].lenR = 0;
    tree[now].lenMax = 0;
    return;
  }
  int mid = (l + r) >> 1;
  init(tree[now].lson, l, mid);
  init(tree[now].rson, mid + 1, r);
  push(tree[now]);
}
void init(int n, int& root0) {
  nodeCnt = 0;
  init(root0, 1, n);
}
void update(int& now, int l, int r, int i) {
  tree[nodeCnt] = tree[now];
  now = nodeCnt++;
  assert(nodeCnt < MAXT);
  if (l == r) {
    tree[now].len = 1;
    tree[now].lenL = 1;
    tree[now].lenR = 1;
    tree[now].lenMax = 1;
    return;
  }
  int mid = (l + r) >> 1;
  if (i <= mid)
    update(tree[now].lson, l, mid, i);
  else
    update(tree[now].rson, mid + 1, r, i);
  push(tree[now]);
  assert(tree[now].len == (r - l + 1));
}
TNode query(int now, int l, int r, int ql, int qr) {
  if (ql == l && qr == r) return tree[now];
  int mid = (l + r) >> 1;
  if (qr <= mid) return query(tree[now].lson, l, mid, ql, qr);
  if (ql > mid) return query(tree[now].rson, mid + 1, r, ql, qr);
  TNode lson, rson, result;
  lson = query(tree[now].lson, l, mid, ql, mid);
  rson = query(tree[now].rson, mid + 1, r, mid + 1, qr);
  push(lson, rson, result);
  return result;
}
int query(int now, int n, int ql, int qr) {
  return query(now, 1, n, ql, qr).lenMax;
}
}  // namespace FST
using FST::init;
using FST::query;
using FST::update;
struct Node {
  int value;
  int index;
} a[MAXN];
int value[MAXN];
int root[MAXN];
bool cmp(const Node& a, const Node& b) { return a.value < b.value; }
int main() {
  int n;
  int cnt;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i].value);
    a[i].index = i;
    value[i] = a[i].value;
  }
  sort(a + 1, a + n + 1, cmp);
  sort(value + 1, value + n + 1);
  cnt = unique(value + 1, value + n + 1) - (value + 1);
  init(n, root[0]);
  for (int i = cnt, j = n; i >= 1; i--) {
    root[i] = root[(i + 1) % (cnt + 1)];
    for (; j >= 1 && a[j].value == value[i]; j--)
      update(root[i], 1, n, a[j].index);
  }
  int m;
  int l, r, w;
  int low, upp, mid;
  scanf("%d", &m);
  for (; m--;) {
    scanf("%d %d %d", &l, &r, &w);
    low = 0;
    upp = cnt + 1;
    for (; upp - low > 1;) {
      mid = (low + upp) >> 1;
      if (query(root[mid], n, l, r) >= w)
        low = mid;
      else
        upp = mid;
    }
    printf("%d\n", value[low]);
  }
  return 0;
}
