#include <bits/stdc++.h>
using namespace std;
int solve2(priority_queue<pair<int, int>> pq, int k, int pos) {
  vector<pair<int, int>> a;
  while (k--) {
    a.push_back(pq.top());
    pq.pop();
  }
  sort(a.begin(), a.end(),
       [&](const pair<int, int>& x, const pair<int, int>& y) {
         return -x.second < -y.second;
       });
  return a[pos - 1].first;
}
void solve() {
  int n, m;
  cin >> n;
  priority_queue<pair<int, int>> pq;
  for (int i = 0; i < n; ++i) {
    int x;
    cin >> x;
    pq.push({x, -i});
  }
  cin >> m;
  while (m--) {
    int k, pos;
    cin >> k >> pos;
    cout << solve2(pq, k, pos) << endl;
  }
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  solve();
  return 0;
}
