#include <bits/stdc++.h>
using namespace std;
struct data {
  int max, left, right;
  data(int m = 0, int l = 0, int r = 0) : max(m), left(l), right(r) {}
};
struct node {
  data ones;
  node *lchild, *rchild;
  node(data d, node *ln, node *rn) : lchild(ln), rchild(rn) { ones = d; }
  data widthinfo(int, int, int, int);
};
int n, heights[100005];
int sortHeight[100005];
node *segTree[100005];
unordered_multimap<int, int> hpos;
node *createTree(int left, int right) {
  if (right == left + 1) return new node(data(0, 0, 0), NULL, NULL);
  return new node(data(0, 0, 0), createTree(left, (left + right) / 2),
                  createTree((left + right) / 2, right));
}
node *modifyTree(vector<int>::iterator lpos, vector<int>::iterator rpos,
                 node *orig, int left, int right) {
  if (lpos == rpos)
    return orig;
  else if (right == left + 1)
    return new node(data(1, 1, 1), NULL, NULL);
  int mid = (left + right) / 2;
  vector<int>::iterator mpos = lower_bound(lpos, rpos, mid);
  node *lc = modifyTree(lpos, mpos, orig->lchild, left, mid);
  node *rc = modifyTree(mpos, rpos, orig->rchild, mid, right);
  int m = max(lc->ones.right + rc->ones.left, max(lc->ones.max, rc->ones.max));
  int l = lc->ones.left + (lc->ones.left == mid - left ? rc->ones.left : 0);
  int r = rc->ones.right + (rc->ones.right == right - mid ? lc->ones.right : 0);
  return new node(data(m, l, r), lc, rc);
}
data node::widthinfo(int left, int right, int start, int end) {
  int mid = (start + end) / 2;
  if (left == start && right == end)
    return ones;
  else if (right <= mid)
    return lchild->widthinfo(left, right, start, mid);
  else if (left >= mid)
    return rchild->widthinfo(left, right, mid, end);
  data ld = lchild->widthinfo(left, mid, start, mid);
  data rd = rchild->widthinfo(mid, right, mid, end);
  int m = max(ld.right + rd.left, max(ld.max, rd.max));
  int l = ld.left + (ld.left == mid - left ? rd.left : 0);
  int r = rd.right + (rd.right == right - mid ? ld.right : 0);
  return data(m, l, r);
}
int binSearch(int start, int end, int left, int right, int width) {
  while (start < end) {
    int mid = (start + end) / 2;
    if (segTree[mid]->widthinfo(left, right, 0, n).max < width)
      end = mid;
    else
      start = mid + 1;
  }
  return sortHeight[start - 1];
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", heights + i);
    sortHeight[i] = heights[i];
    hpos.insert(pair<int, int>(heights[i], i));
  }
  sort(sortHeight, sortHeight + n);
  int numH = 1;
  for (int i = 1; i < n; ++i)
    if (sortHeight[i] != sortHeight[i - 1]) sortHeight[numH++] = sortHeight[i];
  segTree[numH] = createTree(0, n);
  for (int i = numH - 1; i >= 0; --i) {
    auto pp = hpos.equal_range(sortHeight[i]);
    vector<int> pos;
    for (auto itr = pp.first; itr != pp.second; ++itr)
      pos.push_back(itr->second);
    sort(pos.begin(), pos.end());
    segTree[i] = modifyTree(pos.begin(), pos.end(), segTree[i + 1], 0, n);
  }
  int m, l, r, w;
  scanf("%d", &m);
  while (m-- > 0) {
    scanf("%d %d %d\n", &l, &r, &w);
    --l;
    printf("%d\n", binSearch(0, numH, l, r, w));
  }
  return 0;
}
