#include <bits/stdc++.h>
#pragma GCC optimize(2)
#pragma GCC optimize(3)
using namespace std;
int a[200001];
vector<pair<int, int> > v, rem;
struct node {
  int at, pos, ans, id;
} q[200001];
bool cmp(node x, node y) { return x.at < y.at; }
bool cmp2(node x, node y) { return x.id < y.id; }
signed main() {
  int n, m;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    v.push_back(make_pair(-a[i], i));
  }
  sort(v.begin(), v.end());
  scanf("%d", &m);
  for (int i = 1; i <= m; i++) scanf("%d%d", &q[i].at, &q[i].pos), q[i].id = i;
  sort(q + 1, q + m + 1, cmp);
  int j = 1;
  for (int i = 0; i < v.size(); i++) {
    vector<pair<int, int> >::iterator x = lower_bound(
        rem.begin(), rem.end(), make_pair(v[i].second, -v[i].first));
    rem.insert(x, make_pair(v[i].second, -v[i].first));
    while (q[j].at == i + 1 && j <= m) {
      q[j].ans = rem[q[j].pos - 1].second;
      j++;
    }
  }
  sort(q + 1, q + m + 1, cmp2);
  for (int i = 1; i <= m; i++) printf("%d\n", q[i].ans);
  return 0;
}
