#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 1;
int n, q, b[maxn], c[maxn], ans[maxn];
struct node {
  int num, id;
} a[maxn];
struct cxk {
  int k, pos, id;
} s[maxn];
bool cmp(const node &a, const node &b) {
  return a.num == b.num ? a.id < b.id : a.num > b.num;
}
bool cmp2(const cxk &x, const cxk &y) { return x.k < y.k; }
void update(int x) {
  while (x < maxn) c[x]++, x += ((x) & (-x));
}
int query(int x) {
  int res = 0;
  while (x > 0) res += c[x], x -= ((x) & (-x));
  return res;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i)
    scanf("%d", &a[i].num), b[i] = a[i].num, a[i].id = i;
  sort(a + 1, a + 1 + n, cmp);
  scanf("%d", &q);
  for (int i = 1; i <= q; ++i) scanf("%d%d", &s[i].k, &s[i].pos), s[i].id = i;
  sort(s + 1, s + 1 + q, cmp2);
  int k = 1;
  for (int i = 1; i <= q; ++i) {
    while (k <= s[i].k) update(a[k].id), k++;
    int l = 1, r = n;
    while (l < r) {
      int mid = (l + r) >> 1;
      if (query(mid) >= s[i].pos)
        r = mid;
      else
        l = mid + 1;
    }
    ans[s[i].id] = b[l];
  }
  for (int i = 1; i <= q; ++i) printf("%d\n", ans[i]);
}
