#include <bits/stdc++.h>
using namespace std;
struct st {
  int e;
  int in;
};
bool myfunc(st a, st b) {
  if (a.e < b.e)
    return false;
  else if (a.e > b.e)
    return true;
  else {
    if (a.in < b.in)
      return true;
    else
      return false;
  }
}
int main() {
  int n, m;
  cin >> n;
  int a[n], c[n];
  st b[n];
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    b[i].e = a[i];
    b[i].in = i;
  }
  sort(b, b + n, myfunc);
  c[0] = b[0].in;
  for (int i = 1; i < n; ++i) c[i] = min(c[i - 1], b[i].in);
  cin >> m;
  for (int i = 0; i < m; ++i) {
    map<int, int> mp;
    map<int, int>::iterator it;
    int k, p;
    cin >> k >> p;
    for (int j = 0; j < k; ++j) {
      it = mp.find(b[j].e);
      if (it == mp.end())
        mp.insert(pair<int, int>(b[j].e, 1));
      else
        it->second += 1;
    }
    int j = c[k - 1];
    while (p != 0) {
      it = mp.find(a[j]);
      if (it != mp.end()) {
        --p;
        it->second -= 1;
        if (it->second == 0) mp.erase(it);
      }
      ++j;
    }
    --j;
    cout << a[j] << endl;
  }
}
