#include <bits/stdc++.h>
using namespace std;
const int INF = INT_MAX;
bool cmp(int b, pair<int, int> a) { return a.first > b; }
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  int n;
  cin >> n;
  vector<int> a(n);
  for (auto& v : a) cin >> v;
  vector<pair<int, int>> s(n);
  long long sum = 0;
  for (int i = 0; i < n; i++) {
    s[i].first = a[i];
    s[i].second = i;
    sum += a[i];
  }
  sort(s.begin(), s.end());
  vector<vector<int>> ans(n + 1);
  for (int i = 1; i <= n; i++) ans[n].push_back(i);
  for (int i = n - 1; i > 0; i--) {
    ans[i] = ans[i + 1];
    auto pos_s = upper_bound(s.begin(), s.end(), s[0].first, cmp) - 1;
    ans[i].erase(lower_bound(ans[i].begin(), ans[i].end(),
                             s[pos_s - s.begin()].second + 1));
    s.erase(pos_s);
  }
  int m;
  cin >> m;
  while (m--) {
    int k, p;
    cin >> k >> p;
    cout << a[ans[k][p - 1] - 1] << '\n';
  }
}
