#include <bits/stdc++.h>
using namespace std;
long long n;
vector<long long> a;
vector<pair<long long, long long> > b;
bool cmp(pair<long long, long long> a, pair<long long, long long> b) {
  return (a.first < b.first || (a.first == b.first && a.second > b.second));
}
bool comp2(pair<long long, long long> a, pair<long long, long long> b) {
  return a.second < b.second;
}
int main() {
  cin >> n;
  a.resize(n);
  b.resize(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    b[i].first = a[i];
    b[i].second = i;
  }
  sort(b.begin(), b.end(), cmp);
  int m;
  cin >> m;
  vector<vector<pair<long long, long long> > > ans;
  ans.resize(n);
  vector<pair<long long, long long> > h;
  for (int i = 1; i <= n; i++) {
    h.push_back(b[n - i]);
    sort(h.begin(), h.end(), comp2);
    ans[i - 1] = h;
  }
  for (int i = 0; i < m; i++) {
    long long k, pos;
    cin >> k >> pos;
    cout << ans[k - 1][pos - 1].first << "\n";
  }
}
