#include <bits/stdc++.h>
using namespace std;
int A[200010];
vector<pair<int, int> > df, rt;
vector<int> tree[4 * 200010];
void build(int low, int high, int node) {
  if (low == high) {
    tree[node].push_back(rt[low].second);
    return;
  }
  int mid = (low + high) / 2;
  build(low, mid, 2 * node);
  build(mid + 1, high, 2 * node + 1);
  vector<int> temp(high - low + 1);
  tree[node] = temp;
  merge(tree[2 * node].begin(), tree[2 * node].end(),
        tree[2 * node + 1].begin(), tree[2 * node + 1].end(),
        tree[node].begin());
}
int query(int low, int high, int begin, int end, int val, int node) {
  if (low == high) {
    return tree[node][0];
  }
  int p = upper_bound(tree[2 * node].begin(), tree[2 * node].end(), end) -
          lower_bound(tree[2 * node].begin(), tree[2 * node].end(), begin);
  int mid = (low + high) / 2;
  if (p >= val)
    return query(low, mid, begin, end, val, 2 * node);
  else
    return query(mid + 1, high, begin, end, val - p, 2 * node + 1);
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    A[i] = x;
    df.push_back(make_pair(-1 * x, i));
  }
  sort(df.begin(), df.end());
  for (int i = 0; i < df.size(); i++) {
    rt.push_back(make_pair(df[i].second, i));
  }
  sort(rt.begin(), rt.end());
  build(0, n - 1, 1);
  int m;
  cin >> m;
  while (m--) {
    int k, p;
    cin >> k >> p;
    int x = query(0, n - 1, 0, k - 1, p, 1);
    cout << -1 * df[x].first << '\n';
  }
}
