#include <bits/stdc++.h>
using namespace std;
bool cmp(pair<int, int> a, pair<int, int> b) {
  if (a.first == b.first)
    return a.second < b.second;
  else
    return a.first > b.first;
}
bool sortbysec(pair<int, int> a, pair<int, int> b) {
  return (a.second < b.second);
}
int main() {
  int n;
  cin >> n;
  vector<pair<int, int>> v(n);
  vector<int> V(n);
  int a;
  for (int i = 0; i < n; i++) {
    cin >> a;
    v[i] = make_pair(a, i);
    V[i] = a;
  }
  sort(v.begin(), v.end(), cmp);
  int nq;
  cin >> nq;
  int k, pos;
  while (nq--) {
    cin >> k >> pos;
    pos--;
    vector<pair<int, int>> v1(v.begin(), v.begin() + k);
    sort(v1.begin(), v1.end(), sortbysec);
    cout << V[v1[pos].second] << "\n";
  }
}
