#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
const int dx[4] = {0, 0, -1, 1};
const int dy[4] = {-1, 1, 0, 0};
const int N = 2e5 + 1;
int n, Q, Bit[N], b[N];
int ans[N];
pair<int, int> a[N];
void Update(int p) {
  for (; p < N; p += p & -p) Bit[p]++;
}
int Get(int p) {
  int ans = 0;
  for (; p > 0; p -= p & -p) ans += Bit[p];
  return ans;
}
struct Data {
  int k, p, id;
};
Data q[N];
bool comp(pair<int, int> A, pair<int, int> B) {
  return (A.first == B.first) ? (A.second < B.second) : (A.first > B.first);
}
bool comp1(Data A, Data B) { return A.k < B.k; }
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i].first;
    a[i].second = i;
    b[i] = a[i].first;
  }
  sort(a + 1, a + 1 + n, comp);
  cin >> Q;
  for (int i = 1; i <= Q; i++) {
    cin >> q[i].k >> q[i].p;
    q[i].id = i;
  }
  sort(q + 1, q + 1 + Q, comp1);
  int cur = 0;
  for (int i = 1; i <= Q; i++) {
    int k = q[i].k;
    while (cur < k) {
      cur++;
      Update(a[cur].second);
    }
    int l = 1;
    int r = n;
    int p = 0;
    while (l <= r) {
      int m = (l + r) / 2;
      if (Get(m) >= q[i].p) {
        p = m;
        r = m - 1;
      } else {
        l = m + 1;
      }
    }
    ans[q[i].id] = b[p];
  }
  for (int i = 1; i <= Q; i++) cout << ans[i] << '\n';
  return 0;
}
