#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b) {
  while (b) {
    a %= b;
    swap(a, b);
  }
  return a;
}
void ct(vector<int> &a) {
  for (auto &i : a) cout << i << ' ';
  cout << '\n';
}
void ct(vector<pair<int, int>> &a) {
  for (auto &i : a) cout << i.first << ":" << i.second << ' ';
  cout << '\n';
}
void ct(vector<vector<pair<int, int>>> &a) {
  for (auto &i : a) ct(i);
}
void ct(vector<vector<int>> &a) {
  for (auto &i : a) ct(i);
}
void ct(vector<set<int>> &a) {
  for (auto &i : a) {
    for (auto &j : i) cout << j << ' ';
    cout << '\n';
  }
}
void ct(set<pair<int, int>> &a) {
  for (auto &i : a) cout << i.first << ':' << i.second << ' ';
  cout << '\n';
}
void ct(pair<int, int> &a) { cout << a.first << ':' << a.second << '\n'; }
void ci(vector<int> &a) {
  for (int i = 0; i < a.size(); ++i) cin >> a[i];
}
void ci(vector<vector<int>> &a) {
  for (int i = 0; i < a.size(); ++i) ci(a[i]);
}
void think() {}
signed main() {
  int n, m;
  cin >> n;
  vector<pair<int, int>> a;
  for (int i = 0; i < n; ++i) {
    int c;
    cin >> c;
    a.push_back(make_pair(c, -i));
  }
  sort(a.begin(), a.end());
  cin >> m;
  for (int i = 0; i < m; ++i) {
    int k, pos;
    vector<pair<int, int>> ans;
    cin >> k >> pos;
    for (int i = n - k; i < n; ++i) {
      ans.push_back(make_pair(-a[i].second, a[i].first));
    }
    sort(ans.begin(), ans.end());
    cout << ans[pos - 1].second << '\n';
    ans.clear();
  }
}
