#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int> > vec;
vector<tuple<int, int, int> > Que;
const int maxn = 1e5 + 5;
int a[maxn], ans[maxn];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    vec.push_back(pair<int, int>(a[i], -i));
  }
  sort(vec.begin(), vec.end());
  int m;
  cin >> m;
  for (int i = 0; i < m; i++) {
    int k, pos;
    cin >> k >> pos;
    Que.push_back(tuple<int, int, int>(k, pos, i));
  }
  sort(Que.begin(), Que.end());
  int ptr = 0;
  vector<int> S;
  for (int i = 0; i < m; i++) {
    int k = get<0>(Que[i]), pos = get<1>(Que[i]), j = get<2>(Que[i]);
    while (ptr < k) {
      S.push_back(-vec[n - ptr - 1].second);
      ptr++;
    }
    sort(S.begin(), S.end());
    ans[j] = a[S[pos - 1]];
  }
  for (int i = 0; i < m; i++) cout << ans[i] << '\n';
}
