#include <bits/stdc++.h>
using namespace std;
const int MaxN = 1e5 + 1;
const int MOD = 1e9 + 7;
const int inf = 2e9 + 7;
const long long INF = 2e18 + 7;
struct cmp {
  bool operator()(const pair<int, int>& lhs, const pair<int, int>& rhs) {
    if (lhs.first == rhs.first)
      return lhs.second > rhs.second;
    else
      return lhs.first < rhs.first;
  }
};
set<pair<int, int>, cmp> st;
int main() {
  int n;
  cin >> n;
  int a[n];
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    st.insert({a[i], i});
  }
  int m;
  cin >> m;
  for (int i = 0; i < m; ++i) {
    int x, y;
    cin >> x >> y;
    for (int j = 0; j < n; ++j) {
      if (distance(st.find({a[j], j}), st.end()) <= x) {
        if (y == 1) {
          cout << a[j] << '\n';
          break;
        } else
          y--;
      }
    }
  }
}
