#include <bits/stdc++.h>
using namespace std;
bool cmp(pair<int, int> p1, pair<int, int> p2) {
  if (p1.first > p2.first) {
    return true;
  }
  if (p1.first == p2.first && p1.second < p2.second) {
    return true;
  }
  return false;
}
bool cmp1(pair<int, int> p1, pair<int, int> p2) {
  if (p1.second < p2.second) {
    return true;
  }
  return false;
}
int main() {
  long long n;
  cin >> n;
  int a[n + 1];
  vector<pair<int, int> > nums;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    nums.push_back(make_pair(a[i], i));
  }
  sort(nums.begin(), nums.end(), cmp);
  long long m;
  cin >> m;
  vector<pair<int, int> > v[105];
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j < i; j++) {
      v[i].push_back(nums[j]);
    }
    sort(v[i].begin(), v[i].end(), cmp1);
  }
  while (m--) {
    long long k, pos;
    cin >> k >> pos;
    pos--;
    cout << v[k][pos].first << endl;
  }
}
