#include <bits/stdc++.h>
const double PI = 3.141592653589793238460;
using namespace std;
pair<long long int, long long int> ar[200001];
pair<long long int, long long int> st[800004];
pair<int, pair<long long int, long long int> > Q[200005];
int get(int si, int second, int se, int qi) {
  if (second == se) {
    return st[si].first;
  }
  int mid = (second + se) / 2;
  if (st[2 * si].second >= qi) {
    return get(2 * si, second, mid, qi);
  } else {
    return get(2 * si + 1, mid + 1, se, qi - st[2 * si].second);
  }
}
void update(int si, int second, int se, int qi, int val) {
  if (second == se) {
    st[si] = {val, 1};
    return;
  }
  int mid = (second + se) / 2;
  if (qi <= mid)
    update(2 * si, second, mid, qi, val);
  else
    update(2 * si + 1, mid + 1, se, qi, val);
  st[si].second = st[2 * si].second + st[2 * si + 1].second;
}
bool comp(pair<long long int, long long int> a,
          pair<long long int, long long int> b) {
  if (a.first != b.first) return a.first > b.first;
  return a.second < b.second;
}
int ans[200001];
int main() {
  int n, pos, k, q;
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> ar[i].first, ar[i].second = i;
  sort(ar + 1, ar + n + 1, comp);
  cin >> q;
  for (int i = 1; i <= q; i++)
    cin >> Q[i].first >> Q[i].second.first, Q[i].second.second = i;
  sort(Q + 1, Q + q + 1);
  int j = 0;
  for (int i = 1; i <= q; i++) {
    k = Q[i].first;
    pos = Q[i].second.first;
    while (j < k) update(1, 1, n, ar[j + 1].second, ar[j + 1].first), j++;
    ans[Q[i].second.second] = get(1, 1, n, pos);
  }
  for (int i = 1; i <= q; i++) cout << ans[i] << '\n';
}
