#include <bits/stdc++.h>
using namespace std;
int cases = 1;
bool cmp(const pair<int, int>& a, const pair<int, int>& b) {
  if (a.first > b.first)
    return false;
  else if (b.first > a.first)
    return true;
  else if (a.first == b.first) {
    if (a.second < b.second)
      return false;
    else
      return true;
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  int n;
  cin >> n;
  vector<pair<int, int> > v;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    v.push_back(make_pair(x, i + 1));
  }
  sort(v.rbegin(), v.rend(), cmp);
  for (int i = 0; i < n; i++) {
    int t;
    t = v[i].first;
    v[i].first = v[i].second;
    v[i].second = t;
  }
  int t;
  cin >> t;
  while (t--) {
    vector<pair<int, int> > x;
    int m, pos;
    cin >> m >> pos;
    for (int i = 0; i < m; i++) {
      x.push_back(make_pair(v[i].first, v[i].second));
    }
    sort(x.begin(), x.end());
    cout << x[pos - 1].second << endl;
  }
}
