#include <bits/stdc++.h>
using namespace std;
int n, m;
long long a[200005];
int k[200005], pos[200005];
vector<int> vec[200005];
int main(void) {
  scanf("%d", &n);
  vector<long long> vi;
  for (int i = 0; i < n; i++) {
    scanf("%lld", &a[i]);
    vi.push_back(a[i]);
  }
  sort(vi.begin(), vi.end());
  vi.erase(unique(vi.begin(), vi.end()), vi.end());
  for (int i = 0; i < n; i++) {
    a[i] = lower_bound(vi.begin(), vi.end(), a[i]) - vi.begin();
    vec[a[i]].push_back(i);
  }
  scanf("%d", &m);
  for (int i = 0; i < m; i++) {
    scanf("%d%d", &k[i], &pos[i]);
    vector<int> po;
    for (int j = vi.size() - 1; j >= 0; j--) {
      if (po.size() == k[i]) break;
      for (int g = 0; g < vec[j].size(); g++) {
        if (po.size() == k[i]) break;
        po.push_back(vec[j][g]);
      }
    }
    sort(po.begin(), po.end());
    printf("%lld\n", vi[a[po[pos[i] - 1]]]);
  }
  return 0;
}
