#include <bits/stdc++.h>
using namespace std;
long long bigmod(long long a, int p, long long int m) {
  if (p == 0) return 1;
  if (p & 1) {
    return ((a % m) * (bigmod(a, p - 1, m))) % m;
  } else {
    long long tmp = bigmod(a, p / 2, m);
    return (tmp * tmp) % m;
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int n;
  cin >> n;
  pair<long long int, long long int> p[n];
  for (long long int i = 0; i < n; i++) {
    long long int x;
    cin >> x;
    p[i].first = -x;
    p[i].second = i;
  }
  sort(p, p + n);
  vector<long long int> v[n];
  vector<pair<long long int, long long int> > p1;
  for (long long int i = 0; i < n; i++) {
    p1.push_back(make_pair(p[i].second, p[i].first));
    sort(p1.begin(), p1.end());
    for (long long int t = 0; t < p1.size(); t++) {
      v[i].push_back(-p1[t].second);
    }
  }
  long long int m;
  cin >> m;
  while (m--) {
    long long int a;
    cin >> a;
    long long int b;
    cin >> b;
    cout << v[a - 1][b - 1];
    cout << "\n";
  }
  return 0;
}
