#include <bits/stdc++.h>
using namespace std;
void print(vector<int> &A) {
  for (auto a : A) {
    cout << a << " ";
  }
  cout << "\n";
}
bool compare(pair<long long, long long> a, pair<long long, long long> b) {
  return (a.first == b.first ? a.second < b.second : a.first > b.first);
}
long long solve(vector<long long> &A, vector<pair<long long, long long> > &B,
                int n, int k, int pos) {
  vector<long long> vec;
  for (int i = 0; i < k; i++) {
    vec.push_back(B[i].second);
  }
  sort(vec.begin(), vec.end());
  return A[vec[pos - 1]];
}
int main() {
  int n;
  cin >> n;
  vector<long long> A(n);
  for (long long &a : A) {
    cin >> a;
  }
  vector<pair<long long, long long> > B;
  for (int i = 0; i < n; i++) {
    B.push_back({A[i], i});
  }
  sort(B.begin(), B.end(), compare);
  int q;
  cin >> q;
  while (q--) {
    int k, pos;
    cin >> k >> pos;
    cout << solve(A, B, n, k, pos) << "\n";
  }
  return 0;
}
