#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
const double eps = 1e-9;
const int inf = 1e9;
int a[111];
map<int, set<int> > M;
vector<int> ans[111];
bool cmp(pair<int, int> &a, pair<int, int> &b) { return a.second < b.second; }
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    int x;
    scanf("%d", &x);
    a[i] = x;
    M[x].insert(i);
  }
  for (int len = 1; len <= n; len++) {
    vector<pair<int, int> > del;
    vector<int> take;
    int cnt = 0;
    while (cnt != len) {
      auto &pos = (*M.rbegin()).second;
      int num = (*M.rbegin()).first;
      int d = *pos.begin();
      pos.erase(pos.find(d));
      del.push_back({num, d});
      ++cnt;
      if ((int)pos.size() == 0) M.erase((*M.rbegin()).first);
    }
    sort(del.begin(), del.end(), cmp);
    for (auto x : del) {
      ans[len].push_back(a[x.second]);
      M[x.first].insert(x.second);
    }
  }
  int q;
  scanf("%d", &q);
  while (q--) {
    int pos, k;
    scanf("%d%d", &pos, &k);
    swap(pos, k);
    printf("%d\n", ans[k][pos - 1]);
  }
}
