#include <bits/stdc++.h>
using namespace std;
const int MAXN = 110;
const int INF = 1e18 + 7;
const long long MOD = 998244353;
int a[MAXN];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  set<int, greater<int>> s;
  map<int, int> totfreq;
  map<int, vector<int>> totindices;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    totindices[a[i]].push_back(i);
    totfreq[a[i]]++;
    s.insert(a[i]);
  }
  int m;
  cin >> m;
  for (int i = 0; i < m; i++) {
    int k, pos;
    cin >> k >> pos;
    int curk = 0;
    map<int, int> freq;
    set<int> indices;
    for (auto& num : s) {
      if (curk + totfreq[num] <= k) {
        freq[num] = totfreq[num];
      } else {
        freq[num] = k - curk;
      }
      curk += freq[num];
      for (int i = 0; i < freq[num]; i++) {
        indices.insert(totindices[num][i]);
      }
      if (curk == k) {
        break;
      }
    }
    int ans_idx = *next(indices.begin(), pos - 1);
    cout << a[ans_idx] << endl;
  }
}
