#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9 + 5;
const long long linf = 1e18 + 5;
const int N = 1e5 + 5;
class node {
 public:
  int pre, suf, max, len;
};
class tree {
 public:
  node x;
  tree *l, *r;
};
typedef tree* pTree;
int n, m, x, y, k;
pair<int, int> a[N];
pTree kd[N];
node merge(node l, node r) {
  node ans;
  ans.pre = l.pre + (l.pre == l.len) * r.pre;
  ans.suf = r.suf + (r.suf == r.len) * l.suf;
  ans.max = max(max(l.max, r.max), l.suf + r.pre);
  ans.len = l.len + r.len;
  return ans;
}
void init(pTree root, int bas, int son) {
  if (bas == son) {
    root->x = (node){0, 0, 0, 1};
    return;
  }
  root->l = new tree;
  root->r = new tree;
  init(root->l, bas, ((bas + son) >> 1));
  init(root->r, ((bas + son) >> 1) + 1, son);
  root->x = merge(root->l->x, root->r->x);
}
pTree insert(pTree root, int bas, int son, int x) {
  pTree t = new tree;
  if (x <= bas and son <= x) {
    t->x = (node){1, 1, 1, 1};
    return t;
  }
  if (x <= ((bas + son) >> 1)) {
    t->l = insert(root->l, bas, ((bas + son) >> 1), x);
    t->r = root->r;
  } else {
    t->l = root->l;
    t->r = insert(root->r, ((bas + son) >> 1) + 1, son, x);
  }
  t->x = merge(t->l->x, t->r->x);
  return t;
}
node query(pTree root, int bas, int son, int x, int y) {
  if (son < x or y < bas) return (node){0, 0, 0, 0};
  if (x <= bas and son <= y) return root->x;
  return merge(query(root->l, bas, ((bas + son) >> 1), x, y),
               query(root->r, ((bas + son) >> 1) + 1, son, x, y));
}
int main() {
  ios ::sync_with_stdio(0);
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i].first;
    a[i].second = i;
  }
  kd[n + 1] = new tree;
  init(kd[n + 1], 1, n);
  sort(a + 1, a + n + 1);
  for (int i = n; i >= 1; i--) kd[i] = insert(kd[i + 1], 1, n, a[i].second);
  cin >> m;
  for (int i = 1; i <= m; i++) {
    cin >> x >> y >> k;
    int l = 1, r = n;
    while (l + 1 < r) {
      int m = l + r >> 1;
      if (query(kd[m], 1, n, x, y).max >= k)
        l = m;
      else
        r = m - 1;
    }
    if (query(kd[r], 1, n, x, y).max >= k) l = r;
    cout << a[l].first << '\n';
  }
  return 0;
}
