#include <bits/stdc++.h>
using namespace std;
int n, m;
long long w, h;
deque<pair<int, long long> > d;
void read() {
  long long a;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a;
    d.push_back(make_pair(1, a));
  }
}
void solve() {
  cin >> m;
  for (; m; m--) {
    cin >> w >> h;
    long long mx = -1;
    int tmpW = w;
    int idx = 0;
    while (tmpW > 0) {
      if (mx < d[idx].second) mx = d[idx].second;
      tmpW -= d[idx].first;
      idx++;
    }
    cout << mx << endl;
    pair<int, long long> el = make_pair(0, mx + h);
    while (!d.empty() && d[0].second <= el.second) {
      el.first += d[0].first;
      d.pop_front();
    }
    d.push_front(el);
  }
}
int main() {
  read();
  solve();
  return 0;
}
