#include <bits/stdc++.h>
using namespace std;
const int n = 200005;
int t[2 * n];
void build() {
  for (int i = n - 1; i > 0; --i) t[i] = t[i << 1] + t[i << 1 | 1];
}
void modify(int p, int value) {
  for (t[p += n] = value; p > 1; p >>= 1) t[p >> 1] = t[p] + t[p ^ 1];
}
int query(int l, int r) {
  int res = 0;
  for (l += n, r += n; l < r; l >>= 1, r >>= 1) {
    if (l & 1) res += t[l++];
    if (r & 1) res += t[--r];
  }
  return res;
}
bool comp(const pair<int, int> &a, const pair<int, int> &b) {
  if (a.first != b.first) return a.first > b.first;
  return a.second < b.second;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int len;
  cin >> len;
  int arr[len];
  for (int i = 0; i < len; i++) {
    cin >> arr[i];
  }
  pair<int, int> toadd[len];
  for (int i = 0; i < len; i++) {
    toadd[i] = pair<int, int>(arr[i], i);
  }
  sort(toadd, toadd + len, comp);
  int queries;
  cin >> queries;
  int ans[queries];
  vector<vector<pair<int, int> > > asks(len);
  for (int i = 0; i < queries; i++) {
    int amt, pos;
    cin >> amt >> pos;
    amt--;
    asks[amt].push_back(pair<int, int>(pos, i));
  }
  for (int i = 0; i < len; i++) {
    modify(toadd[i].second, 1);
    for (int a = 0; a < asks[i].size(); a++) {
      int kth = asks[i][a].first;
      int low = 0;
      int high = 200005;
      while (low < high) {
        int mid = (low + high) / 2;
        if (query(0, mid + 1) < kth) {
          low = mid + 1;
        } else {
          high = mid;
        }
      }
      ans[asks[i][a].second] = arr[low];
    }
  }
  for (int i = 0; i < queries; i++) {
    cout << ans[i] << endl;
  }
}
