#include <bits/stdc++.h>
using namespace std;
bool arng(pair<long long, long long> p, pair<long long, long long> q) {
  if (p.first > q.first) return true;
  if (p.first == q.first) {
    return (p.second < q.second);
  }
  return false;
}
void solve() {
  long long n, m;
  cin >> n;
  long long ac[n];
  pair<long long, long long> a[n];
  for (long long i = 0; i < n; i++) {
    cin >> a[i].first;
    ac[i] = a[i].first;
    a[i].second = i;
  }
  sort(a, a + n, arng);
  cin >> m;
  while (m--) {
    long long k, pos;
    cin >> k >> pos;
    long long s = 0;
    long long posa[k];
    for (long long i = 0; i < k; i++) {
      posa[i] = a[i].second;
    }
    sort(posa, posa + k);
    cout << ac[posa[pos - 1]] << endl;
  }
  return;
}
int32_t main() { solve(); }
