#include <bits/stdc++.h>
using namespace std;
int n;
const int MAXN = 100 + 1;
vector<int> seq(MAXN);
long long dp[MAXN][MAXN];
long long Dp(int index, int k) {
  if (dp[index][k] != -1) return dp[index][k];
  if (index == n && k != 0) return -1e14;
  if (k == 0 || index == n) return 0;
  long long r;
  r = Dp(index + 1, k);
  r = max(r, Dp(index + 1, k - 1) + seq[index]);
  return dp[index][k] = r;
}
int main() {
  for (int idx1 = 0; idx1 < MAXN; idx1++) {
    for (int idx2 = 0; idx2 < MAXN; idx2++) {
      dp[idx1][idx2] = -1;
    }
  }
  cin >> n;
  vector<pair<int, int>> sortedSeq(n);
  for (int idx = 0; idx < n; idx++) {
    int a;
    cin >> a;
    seq[idx] = a;
    sortedSeq[idx].first = a;
    sortedSeq[idx].second = idx;
  }
  sort(sortedSeq.begin(), sortedSeq.end());
  int q;
  cin >> q;
  while (q--) {
    int k, p;
    cin >> k >> p;
    int minElmPos1 = -1;
    for (int len = 1; len <= k; len++) {
      long long maxSum = LLONG_MIN;
      int minElm = INT_MAX;
      int minElmPos2 = -1;
      for (int idx = 0; idx < sortedSeq.size(); idx++) {
        if (sortedSeq[idx].second <= minElmPos1) continue;
        long long subProblemSum =
            sortedSeq[idx].first + Dp(sortedSeq[idx].second + 1, k - len);
        if (subProblemSum < 0) continue;
        if (subProblemSum > maxSum) {
          maxSum = subProblemSum;
          minElm = sortedSeq[idx].first;
          minElmPos2 = sortedSeq[idx].second;
        }
      }
      minElmPos1 = minElmPos2;
      if (len == p) {
        cout << minElm << endl;
        break;
      }
    }
  }
}
