#include <bits/stdc++.h>
using namespace std;
bool cmp(pair<int, int> a, pair<int, int> b) {
  if (a.first != b.first)
    return a.first > b.first;
  else
    return a.second < b.second;
}
bool cmp2(pair<int, int> a, pair<int, int> b) {
  if (a.second != b.second)
    return a.second < b.second;
  else
    return a.first > b.first;
}
int main() {
  int n, m, x;
  cin >> n;
  vector<pair<int, int> > V, S[n + 1];
  for (int i = 0; i < n; i++) {
    cin >> x;
    V.push_back({x, i});
  }
  sort(V.begin(), V.end(), cmp);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j <= i; j++) {
      S[i].push_back({V[j].first, V[j].second});
    }
    sort(S[i].begin(), S[i].end(), cmp2);
  }
  int a, b;
  cin >> m;
  for (int i = 0; i < m; i++) {
    cin >> a >> b;
    cout << S[a - 1][b - 1].first << endl;
  }
}
