#include <bits/stdc++.h>
using namespace std;
list<pair<int, long long> > l;
long long get(int x) {
  long long ans = 0;
  for (list<pair<int, long long> >::iterator it = l.begin(), e = l.end();
       it != e; ++it) {
    ans = max(ans, it->second);
    if (x <= it->first) {
      break;
    }
    x -= it->first;
  }
  return ans;
}
void update(int ox, long long v) {
  int x = ox;
  list<pair<int, long long> >::iterator now = l.begin(), e = l.end();
  for (; now != e; ++now) {
    if (x < now->first) {
      break;
    }
    x -= now->first;
  }
  while (l.begin() != now) {
    l.pop_front();
  }
  l.begin()->first = l.begin()->first - x;
  l.push_front(make_pair(ox, v));
}
int main() {
  int n, m;
  cin >> n;
  l.clear();
  for (int i = 1; i <= n; i++) {
    long long t;
    cin >> t;
    l.push_back(make_pair(1, t));
  }
  cin >> m;
  for (int i = 0; i < m; i++) {
    int w;
    long long h;
    cin >> w >> h;
    long long ans = get(w);
    cout << ans << "\n";
    update(w, ans + h);
  }
  return 0;
}
