#include <bits/stdc++.h>
using LL = long long;
using ULL = unsigned long long;
using namespace std;
long long n, m;
vector<long long> a;
vector<pair<long long, long long> > vec;
signed main() {
  ios::sync_with_stdio(false), cin.tie(NULL);
  cin >> n;
  a.resize(n, 0);
  vec.resize(n, {0, 0});
  for (long long i = (0); i < (n); i++) cin >> a[i];
  for (long long i = (0); i < (n); i++)
    vec[i].first = a[i], vec[i].second = n - i;
  sort(vec.rbegin(), vec.rend());
  cin >> m;
  for (long long i = (0); i < (m); i++) {
    long long k, pos;
    cin >> k >> pos;
    vector<pair<long long, long long> > tmp;
    tmp.resize(k, {0, 0});
    for (long long i = (0); i < (k); i++)
      tmp[i].first = n - vec[i].second, tmp[i].second = vec[i].first;
    sort(tmp.begin(), tmp.end());
    cout << tmp[pos - 1].second << '\n';
  }
  return 0;
}
