#include <bits/stdc++.h>
using namespace std;
const long long maxn = 1000001;
long long n, inp[maxn], g[maxn], en[maxn];
long long tim, w, h, top;
int main() {
  scanf("%I64d", &n);
  for (long long i = 1; i <= n; ++i) scanf("%I64d", &inp[i]);
  for (long long i = n; i >= 1; --i) {
    g[++top] = inp[i];
    en[top] = i;
  }
  scanf("%I64d", &tim);
  while (tim--) {
    scanf("%I64d%I64d", &w, &h);
    long long ma = 0;
    while (en[top] < w) {
      ma = ((ma) > (g[top]) ? (ma) : (g[top]));
      top--;
    }
    ma = ((ma) > (g[top]) ? (ma) : (g[top]));
    if (en[top] == w) top--;
    en[++top] = w;
    g[top] = h + ma;
    printf("%I64d\n", ma);
  }
  return 0;
}
