#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100005;
int n, m;
struct Box {
  int w;
  long long h;
  long long height;
} box[MAXN];
struct Interval {
  int l, r;
  long long h;
  int id;
  bool tag;
} in[MAXN << 2];
long long Max(long long x, long long y) { return x > y ? x : y; }
int MaxId(int i, int j) {
  return box[in[i].id].height + box[in[i].id].h >
                 box[in[j].id].height + box[in[j].id].h
             ? in[i].id
             : in[j].id;
}
void Build(int left, int right, int root) {
  in[root].l = left;
  in[root].r = right;
  in[root].id = 0;
  in[root].tag = false;
  if (left == right) {
    scanf("%I64d", &in[root].h);
    return;
  }
  int mid = (left + right) >> 1;
  Build(left, mid, root << 1);
  Build(mid + 1, right, root << 1 | 1);
  in[root].h = Max(in[root << 1].h, in[root << 1 | 1].h);
}
void Update(int from, int to, int root, int idx) {
  if (from <= in[root].l && to >= in[root].r) {
    in[root].tag = true;
    if (!in[root].id)
      box[idx].height = Max(box[idx].height, in[root].h);
    else
      box[idx].height =
          Max(box[idx].height, box[in[root].id].height + box[in[root].id].h);
    in[root].id = idx;
    return;
  }
  int mid = (in[root].l + in[root].r) >> 1;
  if (in[root].tag) {
    in[root << 1].id = in[root << 1 | 1].id = in[root].id;
    in[root << 1].tag = in[root << 1 | 1].tag = true;
    in[root].tag = false;
  }
  if (from <= mid) Update(from, to, root << 1, idx);
  if (to > mid) Update(from, to, root << 1 | 1, idx);
  int maxId = MaxId(root << 1, root << 1 | 1);
  in[root].id = in[root].h > box[maxId].height + box[maxId].h ? 0 : maxId;
}
int main() {
  while (scanf("%d", &n) != EOF) {
    Build(1, n, 1);
    scanf("%d", &m);
    box[0].height = box[0].h = 0;
    for (int i = 1; i <= m; i++) {
      scanf("%d %I64d", &box[i].w, &box[i].h);
      box[i].height = 0;
      Update(1, box[i].w, 1, i);
    }
    for (int i = 1; i <= m; i++) printf("%I64d\n", box[i].height);
  }
  return 0;
}
