#include <bits/stdc++.h>
const long long mod = 1e9 + 7;
const long long INF = 9 * 1e18;
using namespace std;
bool cmp1(pair<long long, long long> x, pair<long long, long long> y) {
  if (x.first != y.first) return x.first > y.first;
  return x.second < y.second;
}
bool cmp2(pair<long long, long long> x, pair<long long, long long> y) {
  return x.second < y.second;
}
void solve() {
  long long n, a, b;
  cin >> n;
  vector<long long> ar(n);
  set<long long> st;
  vector<pair<long long, long long>> work;
  for (long long i = 0; i < n; i++) {
    cin >> ar[i];
    work.push_back({ar[i], i});
  }
  sort(work.begin(), work.end(), cmp1);
  long long q;
  cin >> q;
  vector<pair<long long, long long>> input;
  map<pair<long long, long long>, long long> mp;
  list<long long> adj[n + 1];
  for (int i = 0; i < q; i++) {
    cin >> a >> b;
    input.push_back({a, b});
    st.insert(a);
    adj[a].push_back(b);
  }
  for (auto it : st) {
    sort(work.begin(), work.begin() + it, cmp2);
    for (auto it1 : adj[it]) {
      mp[{it, it1}] = work[it1 - 1].first;
    }
    sort(work.begin(), work.begin() + it, cmp1);
  }
  for (int i = 0; i < input.size(); i++) {
    long long a = input[i].first;
    long long b = input[i].second;
    cout << mp[{a, b}] << endl;
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long q = 1;
  while (q--) {
    solve();
  }
  return 0;
}
