#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  int arr[n], barr[n];
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
    barr[i] = arr[i];
  }
  sort(arr, arr + n);
  int t;
  cin >> t;
  while (t--) {
    int k, pos;
    cin >> k >> pos;
    map<int, int> m;
    for (int i = 0; i < k; i++) m[arr[n - i - 1]]++;
    int c = 0;
    for (int i = 0; i < n; i++) {
      int p;
      if (m[barr[i]] > 0) {
        c++;
        p = barr[i];
        m[barr[i]]--;
      }
      if (c == pos) {
        cout << p << "\n";
        break;
      }
    }
  }
  return 0;
}
