#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n;
  cin >> n;
  vector<int> a(n), b(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    b[i] = a[i];
  }
  sort((b).begin(), (b).end());
  reverse((b).begin(), (b).end());
  int m;
  cin >> m;
  for (int i = 0; i < m; ++i) {
    int k, pos;
    cin >> k >> pos;
    set<int> largest;
    vector<int> l;
    for (int i = 0; i < k; ++i) {
      largest.insert(b[i]);
      l.push_back(b[i]);
    }
    reverse((l).begin(), (l).end());
    vector<int> tmp;
    for (int i : a) {
      if (largest.find(i) != largest.end()) {
        tmp.push_back(i);
      }
    }
    vector<bool> selected(tmp.size());
    for (int i = 0; i < k; ++i) {
      bool smaller = false;
      int correctIndex = -1;
      for (int j = 0; j < tmp.size(); ++j) {
        if (tmp[j] == l[i] && !selected[j]) {
          if (correctIndex == -1) {
            correctIndex = j;
          } else {
            if (smaller) {
              correctIndex = j;
              smaller = false;
            }
          }
        } else if (tmp[j] < l[i] && selected[j]) {
          smaller = true;
        }
      }
      selected[correctIndex] = true;
    }
    vector<int> ans;
    for (int i = 0; i < tmp.size(); ++i) {
      if (selected[i]) {
        ans.push_back(tmp[i]);
      }
    }
    cout << ans[pos - 1] << '\n';
  }
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.precision(10);
  int ts = 1;
  for (int i = 1; i <= ts; ++i) {
    solve();
  }
  return 0;
}
