#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 10;
const int mod = 1e9 + 7;
int read() {
  int x = 0, f = 1;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') x = (x << 1) + (x << 3) + c - '0', c = getchar();
  return x * f;
}
map<int, vector<int>> pos;
int main() {
  int n, m;
  cin >> n;
  vector<int> a(n + 1);
  vector<pair<int, int>> b(n + 1);
  for (int i = 1; i <= n; i++)
    cin >> a[i], b[i] = {a[i], i}, pos[a[i]].push_back(i);
  sort(b.begin() + 1, b.end(), greater<pair<int, int>>());
  cin >> m;
  while (m--) {
    int k = read(), j = read();
    vector<int> tmp;
    int cnt = 0;
    for (int i = 1; i <= k; i++) {
      if (b[i].first != b[k].first) {
        cnt++;
        tmp.push_back(b[i].second);
      }
    }
    auto z = pos[b[k].first];
    for (int i = 0; i < k - cnt; i++) tmp.push_back(z[i]);
    sort(tmp.begin(), tmp.end());
    cout << a[tmp[j - 1]] << endl;
  }
}
