#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, i, j, k, p, m, l, q, count = 0, mod = 998244353;
  cin >> n;
  vector<pair<int, int>> a;
  for (i = 0; i < n; i++) {
    cin >> p;
    a.push_back(make_pair(-p, i));
  }
  sort(a.begin(), a.end());
  cin >> m;
  vector<pair<int, int>> b;
  int c[m];
  for (i = 0; i < m; i++) {
    cin >> p >> c[i];
    b.push_back(make_pair(p, i));
  }
  sort(b.begin(), b.end());
  i = 0;
  k = 0;
  int d[m];
  map<int, int> ma;
  while (k < m) {
    while (i < b[k].first) {
      ma[a[i].second] = -a[i].first;
      i++;
    }
    auto itr = ma.begin();
    l = c[b[k].second] - 1;
    advance(itr, l);
    d[b[k].second] = itr->second;
    k++;
  }
  for (i = 0; i < m; i++) {
    cout << d[i] << endl;
  }
}
