#include <bits/stdc++.h>
using namespace std;
struct state {
  int l, r, o, len;
};
struct node {
  int lo, hi;
  state s;
  node *left, *right;
};
state null;
int n, m, cur = 0;
node meh[2000000];
node* h[200000];
vector<pair<int, int> > moo;
node* init(int lo, int hi) {
  node* x = &meh[cur++];
  x->lo = lo, x->hi = hi;
  x->s.l = 0, x->s.r = 0, x->s.o = 0, x->s.len = hi - lo + 1;
  if (lo == hi) {
    x->left = NULL;
    x->right = NULL;
  } else {
    x->left = init(lo, (lo + hi) / 2);
    x->right = init((lo + hi) / 2 + 1, hi);
  }
  return x;
}
state merge(state a, state b) {
  state s;
  s.len = a.len + b.len;
  s.l = a.l;
  if (s.l == a.len) s.l += b.l;
  s.r = b.r;
  if (s.r == b.len) s.r += a.r;
  s.o = max(max(a.o, b.o), a.r + b.l);
  return s;
}
node* insert(node* at, int loc) {
  if (at->lo > loc || at->hi < loc) return at;
  node* x = &meh[cur++];
  *x = *at;
  if (at->lo == at->hi) {
    x->s.len = 1, x->s.l = 1, x->s.r = 1, x->s.o = 1;
  } else {
    *x = *at;
    x->left = insert(x->left, loc);
    x->right = insert(x->right, loc);
    x->s = merge(x->left->s, x->right->s);
  }
  return x;
}
int vis = 0;
state go(node* at, int l, int r, int w) {
  vis++;
  if (at->lo >= l && at->hi <= r) return at->s;
  if (at->left->hi < l) return go(at->right, l, r, w);
  if (at->right->lo > r) return go(at->left, l, r, w);
  state a = go(at->left, l, r, w);
  state b = go(at->right, l, r, w);
  if (a.o >= w) return a;
  if (b.o >= w) return b;
  return merge(a, b);
}
int main() {
  scanf("%d", &n);
  null.l = 0, null.r = 0, null.len = 0, null.o = 0;
  h[0] = init(1, n);
  for (int i = 0; i < n; i++) {
    int a;
    scanf("%d", &a);
    moo.push_back(make_pair(a, i + 1));
  }
  sort(moo.rbegin(), moo.rend());
  for (int i = 1; i <= n; i++) {
    h[i] = insert(h[i - 1], moo[i - 1].second);
  }
  scanf("%d", &m);
  for (int i = 0; i < m; i++) {
    int l, r, w;
    scanf("%d %d %d", &l, &r, &w);
    int lo = w, hi = n;
    while (lo != hi) {
      int mid = (lo + hi) / 2;
      state s = go(h[mid], l, r, w);
      if (s.o >= w) {
        hi = mid;
      } else {
        lo = mid + 1;
      }
    }
    assert(lo != 0);
    printf("%d\n", moo[lo - 1].first);
  }
}
