#include <bits/stdc++.h>
using namespace std;
const long long inf = 2147383647;
const double pi = 2 * acos(0.0);
const double eps = 1e-9;
struct debugger {
  template <typename T>
  debugger &operator,(const T &v) {
    cerr << v << " ";
    return *this;
  }
} dbg;
inline long long gcd(long long a, long long b) {
  a = ((a) < 0 ? -(a) : (a));
  b = ((b) < 0 ? -(b) : (b));
  while (b) {
    a = a % b;
    swap(a, b);
  }
  return a;
}
int ext_gcd(int a, int b, int &x, int &y) {
  if (a == 0) {
    x = 0;
    y = 1;
    return b;
  }
  int x1, y1;
  int d = ext_gcd(b % a, a, x1, y1);
  x = y1 - (b / a) * x1;
  y = x1;
  return d;
}
inline long long modInv(int a, int m) {
  int x, y;
  ext_gcd(a, m, x, y);
  if (x < 0) x += m;
  return x;
}
inline long long power(long long a, long long p) {
  long long res = 1, x = a;
  while (p) {
    if (p & 1) res = (res * x);
    x = (x * x);
    p >>= 1;
  }
  return res;
}
inline long long bigmod(long long a, long long p, long long m) {
  long long res = 1, x = a % m;
  while (p) {
    if (p & 1) res = (res * x) % m;
    x = (x * x) % m;
    p >>= 1;
  }
  return res;
}
int n;
int arr[100010], renum[100010], ind, mapping[100010], head[100010];
map<int, int> mp;
vector<int> numPos[100010];
struct node {
  int lft, rgt, pref, suf, one, len;
} tnode[3000000];
void build(int t, int b, int e) {
  int m = (b + e) / 2;
  if (b == e) {
    tnode[t].len = 1;
    return;
  }
  tnode[t].lft = ind++;
  tnode[t].rgt = ind++;
  build(tnode[t].lft, b, m);
  build(tnode[t].rgt, m + 1, e);
  tnode[t].len = tnode[tnode[t].lft].len + tnode[tnode[t].rgt].len;
}
void mergeNode(node &p, node &u, node &v) {
  p.pref = u.pref;
  if (u.pref == u.len) p.pref = u.pref + v.pref;
  p.suf = v.suf;
  if (v.suf == v.len) p.suf = v.suf + u.suf;
  p.one = ((p.pref) > (p.suf) ? (p.pref) : (p.suf));
  p.one = ((p.one) > (u.suf + v.pref) ? (p.one) : (u.suf + v.pref));
  p.one = ((p.one) > (u.one) ? (p.one) : (u.one));
  p.one = ((p.one) > (v.one) ? (p.one) : (v.one));
  p.len = u.len + v.len;
}
int stx, sty;
int update(int t, int b, int e) {
  int m = (b + e) / 2;
  if (b >= stx && e <= sty) {
    tnode[ind].pref = tnode[ind].suf = tnode[ind].one = tnode[ind].len = 1;
    ind++;
    return ind - 1;
  }
  if (e < stx || b > sty) {
    return t;
  }
  int xind = ind;
  ind++;
  int u, v;
  u = tnode[xind].lft = update(tnode[t].lft, b, m);
  v = tnode[xind].rgt = update(tnode[t].rgt, m + 1, e);
  mergeNode(tnode[xind], tnode[u], tnode[v]);
  return xind;
}
node stq, stq2;
int stFlag;
void query(int t, int b, int e) {
  int m = (b + e) / 2;
  if (b >= stx && e <= sty) {
    if (stFlag == 0) {
      stFlag = 1;
      stq = tnode[t];
    } else {
      stq2 = stq;
      mergeNode(stq, stq2, tnode[t]);
    }
    return;
  }
  if (e < stx || b > sty) {
    return;
  }
  query(tnode[t].lft, b, m);
  query(tnode[t].rgt, m + 1, e);
}
int main() {
  scanf("%d", &n);
  for (int i = (1); i <= (n); ++i) {
    scanf("%d", &arr[i]);
    renum[i] = arr[i];
  }
  sort(renum + 1, renum + 1 + n);
  int num = 1;
  for (int i = (1); i <= (n); ++i) {
    if (renum[i] != renum[i - 1]) {
      mp[renum[i]] = num++;
      mapping[num - 1] = renum[i];
    }
  }
  for (int i = (1); i <= (n); ++i) {
    arr[i] = mp[arr[i]];
    numPos[arr[i]].push_back(i);
  }
  ind = 1;
  head[0] = 0;
  build(0, 1, n);
  int last = 0;
  for (int i = (num - 1); i >= (1); --i) {
    for (int j = (0); j <= (((int)(numPos[i]).size()) - 1); ++j) {
      int x = numPos[i][j];
      stx = x;
      sty = x;
      head[i] = update(last, 1, n);
      last = head[i];
    }
  }
  int m;
  scanf("%d", &m);
  while (m--) {
    int l, r, w;
    scanf("%d %d %d", &l, &r, &w);
    stx = l;
    sty = r;
    int low = 1, high = num - 1;
    while (low <= high) {
      int mid = (low + high) / 2;
      stFlag = 0;
      query(head[mid], 1, n);
      if (stq.one >= w)
        low = mid + 1;
      else
        high = mid - 1;
    }
    printf("%d\n", mapping[low - 1]);
  }
  return 0;
}
