#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<pair<int, int>> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i].first;
    a[i].second = i;
  }
  sort(a.begin(), a.end(),
       [](const pair<int, int>& a, const pair<int, int>& b) {
         if (a.first == b.first) return a.second < b.second;
         return a.first > b.first;
       });
  vector<vector<pair<int, int>>> b(n);
  for (int i = 0; i < n; i++) {
    if (i) b[i] = b[i - 1];
    b[i].push_back(a[i]);
    sort(b[i].begin(), b[i].end(),
         [](const pair<int, int>& a, const pair<int, int>& b) {
           return a.second < b.second;
         });
  }
  int m;
  cin >> m;
  for (int i = 0; i < m; i++) {
    int k, pos;
    cin >> k >> pos;
    cout << b[k - 1][pos - 1].first << "\n";
  }
  return 0;
}
