#include <bits/stdc++.h>
using namespace std;
vector<int> tab[101];
bool cmp(pair<int, int>& p1, pair<int, int>& p2) {
  if (p1.first < p2.first) return true;
  if (p1.first == p2.first) return p1.second < p2.second;
  return false;
}
void calc(int a, vector<int> v, vector<int> vuns) {
  bool vis[101];
  for (int i = 0; i < 101; i++) vis[i] = false;
  vector<int> vsub;
  int x = v.size() - a;
  for (int i = x; i < v.size(); i++) vsub.push_back(v[i]);
  int un = vsub[0];
  vector<int> vsubuniq;
  vsubuniq.push_back(un);
  for (int i = 1; i < vsub.size(); i++) {
    if (vsub[i] != un) {
      vsubuniq.push_back(vsub[i]);
      un = vsub[i];
    }
  }
  vector<pair<int, int>> pos;
  for (int i = 0; i < vsubuniq.size(); i++) {
    for (int j = 0; j < vuns.size(); j++) {
      if (vsubuniq[i] == vuns[j]) {
        pos.push_back(make_pair(vuns[j], j));
      }
    }
  }
  sort(pos.begin(), pos.end(), cmp);
  vector<pair<int, int>> ans;
  for (int i = 0; i < vsub.size(); i++) {
    for (int j = 0; j < vuns.size(); j++) {
      if (vuns[j] == vsub[i] && !vis[j]) {
        vis[j] = true;
        ans.push_back(make_pair(j, vsub[i]));
        break;
      }
    }
  }
  sort(ans.begin(), ans.end());
  for (int i = 0; i < ans.size(); i++) {
    tab[a].push_back(ans[i].second);
  }
}
void start() {
  int n, a;
  cin >> n;
  vector<int> v, vuns;
  for (int i = 0; i < n; i++) {
    cin >> a;
    v.push_back(a);
    vuns.push_back(a);
  }
  sort(v.begin(), v.end());
  int m, b;
  cin >> m;
  for (int i = 0; i < m; i++) {
    cin >> a >> b;
    if (tab[a].size() == 0) {
      calc(a, v, vuns);
    }
    cout << tab[a][b - 1] << "\n";
  }
}
int main() {
  start();
  return 0;
}
