#include <bits/stdc++.h>
using namespace std;
int n;
struct node {
  int pre, sub;
  int bst;
  int l, r;
};
int a[100100], ps[100100];
int nxt = 1;
node nd[100100 * 20];
int rz[100100];
bool re(int q, int w) { return a[q] < a[w]; }
void build(int pos, int ini, int fin) {
  if (ini == fin) return;
  int mit = (ini + fin) >> 1;
  int left = nd[pos].l = ++nxt;
  int right = nd[pos].r = ++nxt;
  build(left, ini, mit);
  build(right, mit + 1, fin);
}
int update(int pos, int ini, int fin, int ind) {
  if (ini > ind || fin < ind) return pos;
  int yo = ++nxt;
  if (ini == fin) {
    nd[yo].pre = nd[yo].bst = nd[yo].sub = 1;
    return yo;
  }
  int mit = (ini + fin) >> 1;
  int left = nd[yo].l = update(nd[pos].l, ini, mit, ind);
  int right = nd[yo].r = update(nd[pos].r, mit + 1, fin, ind);
  nd[yo].bst = max(nd[left].bst, nd[right].bst);
  if (nd[left].bst == mit - ini + 1)
    nd[yo].pre = nd[left].bst + nd[right].pre;
  else
    nd[yo].pre = nd[left].pre;
  if (nd[right].bst == (fin - (mit + 1)) + 1)
    nd[yo].sub = nd[right].bst + nd[left].sub;
  else
    nd[yo].sub = nd[right].sub;
  nd[yo].bst = max(nd[yo].bst, nd[left].sub + nd[right].pre);
  return yo;
}
node dead, clean;
int ri, rf, w;
node query(int pos, int ini, int fin) {
  if (ini > rf || fin < ri) return dead;
  if (ri <= ini && fin <= rf) return nd[pos];
  int mit = (ini + fin) >> 1;
  node yo = clean;
  node left = query(nd[pos].l, ini, mit);
  node right = query(nd[pos].r, mit + 1, fin);
  yo.bst = max(left.bst, right.bst);
  if (left.bst == mit - ini + 1)
    yo.pre = left.bst + right.pre;
  else
    yo.pre = left.pre;
  if (right.bst == (fin - (mit + 1)) + 1)
    yo.sub = right.bst + left.sub;
  else
    yo.sub = right.sub;
  yo.bst = max(yo.bst, left.sub + right.pre);
  return yo;
}
node tem;
int bin(int ini, int fin) {
  int mit;
  int sol;
  while (ini <= fin) {
    mit = (ini + fin) >> 1;
    if (query(rz[mit], 1, n).bst >= w) {
      sol = mit;
      ini = mit + 1;
    } else
      fin = mit - 1;
  }
  return a[ps[sol]];
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    ps[i] = i;
  }
  sort(ps + 1, ps + n + 1, re);
  rz[n + 1] = 1;
  build(1, 1, n);
  dead.bst = dead.pre = dead.sub = 0;
  clean.bst = clean.pre = clean.sub = 0;
  for (int i = n; i >= 1; i--) {
    rz[i] = update(rz[i + 1], 1, n, ps[i]);
  }
  int q;
  cin >> q;
  while (q--) {
    cin >> ri >> rf >> w;
    cout << bin(1, n) << endl;
  }
  return 0;
}
