#include <bits/stdc++.h>
using namespace std;
clock_t __stt;
inline void TStart() { __stt = clock(); }
inline void TReport() {
  printf("\nTaken Time : %.3lf sec\n",
         (double)(clock() - __stt) / CLOCKS_PER_SEC);
}
template <typename T>
T MIN(T a, T b) {
  return a < b ? a : b;
}
template <typename T>
T MAX(T a, T b) {
  return a > b ? a : b;
}
template <typename T>
T ABS(T a) {
  return a > 0 ? a : (-a);
}
template <typename T>
void UMIN(T &a, T b) {
  if (b < a) a = b;
}
template <typename T>
void UMAX(T &a, T b) {
  if (b > a) a = b;
}
int n, m;
vector<pair<int, int> > col;
set<int> st;
class node {
 public:
  int v, maxv, cnt;
  node *lc, *rc;
  node(int mv = 0, int sv = -1) {
    v = sv;
    maxv = mv;
    cnt = 0;
    lc = rc = NULL;
  }
  inline void pull() { maxv = MAX((lc ? lc->maxv : 0), (rc ? rc->maxv : 0)); }
  inline void push(bool dl, bool dr) {
    node *ori;
    if (dl && (v > -1 || !lc)) {
      ori = lc;
      lc = new node(v, v);
      if (ori) {
        lc->cnt = ori->cnt;
        lc->lc = ori->lc;
        lc->rc = ori->rc;
      }
    }
    if (dr && (v > -1 || !rc)) {
      ori = rc;
      rc = new node(v, v);
      if (ori) {
        rc->cnt = ori->cnt;
        rc->lc = ori->lc;
        rc->rc = ori->rc;
      }
    }
  }
  int query(int L, int R, int l = 0, int r = n - 1) {
    if (L > R) return -1;
    if (v > -1) return v;
    if (l >= L && r <= R) return maxv;
    int M = (l + r) >> 1, ret = v;
    if (L <= M && lc) UMAX(ret, lc->query(L, R, l, M));
    if (R > M && rc) UMAX(ret, rc->query(L, R, M + 1, r));
    return ret;
  }
  int lower_bound(int pos, int l = 0, int r = n - 1) {
    if (!cnt) return -1;
    if (l == r) return l;
    int M = (l + r) >> 1, ret = -1;
    if (pos <= M && lc) ret = lc->lower_bound(pos, l, M);
    if (ret == -1 && rc) ret = rc->lower_bound(pos, M + 1, r);
    return ret;
  }
  int rev_lbound(int pos, int l = 0, int r = n - 1) {
    if (!cnt) return -1;
    if (l == r) return l;
    int M = (l + r) >> 1, ret = -1;
    if (pos > M && rc) ret = rc->rev_lbound(pos, M + 1, r);
    if (ret == -1 && lc) ret = lc->rev_lbound(pos, l, M);
    return ret;
  }
  void add(int pos, int l, int r) {
    ++cnt;
    if (l == r) return;
    int M = (l + r) >> 1;
    if (pos <= M) {
      push(1, 0);
      lc->add(pos, l, M);
    } else {
      push(0, 1);
      rc->add(pos, M + 1, r);
    }
  }
  node *modify(int L, int R, bool adl, int val, int l = 0, int r = n - 1) {
    node *ret = new node();
    *ret = *this;
    if (L > R) return ret;
    if (l >= L && r <= R) {
      ret->v = ret->maxv = val;
      if (adl && l == L) ret->add(L, l, r);
      return ret;
    }
    ret->push(1, 1);
    if (val != v) ret->v = -1;
    int M = (l + r) >> 1;
    if (L <= M) ret->lc = ret->lc->modify(L, R, adl, val, l, M);
    if (R > M) ret->rc = ret->rc->modify(L, R, adl, val, M + 1, r);
    if (l <= L && r >= L) ret->cnt += (int)adl;
    ret->pull();
    return ret;
  }
} * root[100005];
inline bool check(int pos, int l, int r, int w) {
  node *sor = root[pos + 1];
  int cl = sor->lower_bound(l), cr = sor->rev_lbound(r);
  if (cl > r || cl == -1)
    return 1;
  else if (cl - l >= w || r - cr >= w)
    return 1;
  else
    return sor->query(cl + 1, cr - 1) >= w;
}
int main() {
  scanf("%d", &n);
  int xb, h;
  for (xb = 0; xb < n; ++xb) {
    scanf("%d", &h);
    col.push_back(make_pair(h, xb));
  }
  root[0] = new node(n, n);
  sort(col.begin(), col.end());
  st.insert(-1);
  st.insert(n);
  for (xb = 0; xb < n; ++xb) {
    int pos = col[xb].second, s, e;
    set<int>::iterator it = st.upper_bound(pos);
    e = *it;
    s = *(--it);
    st.insert(pos);
    root[xb + 1] = (root[xb]->modify(MAX(0, s), pos, 0, pos - s - 1))
                       ->modify(pos, MIN(n - 1, e), 1, e - pos - 1);
  }
  scanf("%d", &m);
  for (xb = 0; xb < m; ++xb) {
    int l, r, w, low = -1, high = n - 2, mid;
    scanf("%d%d%d", &l, &r, &w);
    --l;
    --r;
    while (low < high) {
      mid = (low + high + 1) >> 1;
      if (check(mid, l, r, w))
        low = mid;
      else
        high = mid - 1;
    }
    printf("%d\n", col[low + 1].first);
  }
  return 0;
}
