#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 5, maxt = maxn * 20;
pair<int, int> a[maxn + 1];
int root[maxn + 1];
int n;
void read() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i].first);
    a[i].second = i;
  }
  sort(a + 1, a + 1 + n);
}
struct node {
  int l, r, lv, rv, t;
} zero;
struct segTree {
  int ch[maxt + 1][2], tt;
  node a[maxt + 1];
  void init() {
    tt = 0;
    buildtree(root[n + 1], 1, n);
    zero.lv = zero.rv = zero.t = 0;
  }
  void buildtree(int &x, int l, int r) {
    x = ++tt;
    a[x].l = l;
    a[x].r = r;
    if (l == r) {
      ch[x][0] = ch[x][1] = 0;
      a[x].lv = a[x].rv = a[x].t = 0;
      return;
    }
    buildtree(ch[x][0], l, ((l + r) >> 1));
    buildtree(ch[x][1], ((l + r) >> 1) + 1, r);
  }
  node upd(node a, node b) {
    node c;
    if (a.t == a.r - a.l + 1)
      c.lv = a.t + b.lv;
    else
      c.lv = a.lv;
    if (b.t == b.r - b.l + 1)
      c.rv = a.rv + b.t;
    else
      c.rv = b.rv;
    c.t = max(max(a.t, b.t), a.rv + b.lv);
    c.l = a.l;
    c.r = b.r;
    assert(b.l - a.r == 1);
    return c;
  }
  int inser(int x, int p, int l = 1, int r = -1) {
    if (r == -1) r = n;
    if (p < l || p > r) return x;
    int ans = ++tt;
    a[ans].l = a[x].l;
    a[ans].r = a[x].r;
    if (l == r) {
      a[ans].lv = a[ans].rv = a[ans].t = 1;
      return ans;
    }
    ch[ans][0] = inser(ch[x][0], p, l, ((l + r) >> 1));
    ch[ans][1] = inser(ch[x][1], p, ((l + r) >> 1) + 1, r);
    a[ans] = upd(a[ch[ans][0]], a[ch[ans][1]]);
    return ans;
  }
  node q(int x, int le, int ri, int l = 1, int r = -1) {
    if (r == -1) r = n;
    if (ri < l || r < le) {
      zero.l = l;
      zero.r = r;
      return zero;
    }
    if (le <= l && r <= ri) {
      return a[x];
    }
    return upd(q(ch[x][0], le, ri, l, ((l + r) >> 1)),
               q(ch[x][1], le, ri, ((l + r) >> 1) + 1, r));
  }
} T;
void work() {
  T.init();
  for (int i = n; i > 0; i--) root[i] = T.inser(root[i + 1], a[i].second);
  assert(T.q(root[1], 1, n).t == n);
  int m, l, r, w, le, ri;
  scanf("%d", &m);
  for (int i = 1; i <= m; i++) {
    scanf("%d%d%d", &le, &ri, &w);
    int l = 1, r = n;
    while (l != r) {
      int M = (l + r) / 2 + 1;
      if (T.q(root[M], le, ri).t >= w)
        l = M;
      else
        r = M - 1;
    }
    printf("%d\n", a[l].first);
  }
}
int main() {
  read();
  work();
  return 0;
}
