#include <bits/stdc++.h>   using namespace std;   long long tree[4 * 100100];   long long a[100100];   int n;   void build(int from, int to, int node) {     if (from == to) {       tree[node] = a[from];       return;     }     int mid = (from + to) / 2;     build(from, mid, 2 * node);     build(mid + 1, to, 2 * node + 1);     tree[node] = max(tree[2 * node], tree[2 * node + 1]);   }   long long val;   void update(int from, int to, int node) {     if (from == to) {       tree[node] = val;       return;     }     int mid = (from + to) / 2;     update(from, mid, 2 * node);     tree[node] = max(tree[2 * node], tree[2 * node + 1]);   }   long long query(int from, int to, int node, int low, int high) {     if (low > to || from > high) {       return 0;     }     if (from >= low && to <= high) {       return tree[node];     }     int mid = (from + to) / 2;     return max(query(from, mid, 2 * node, low, high),                query(mid + 1, high, 2 * node + 1, low, high));   }   long long b[100100];   int main() {     scanf( %d , &n);     for (int i = 0; i < n; i++) {       cin >> a[i];     }     b[0] = a[0];     b[1] = a[1];     for (int i = 2; i < n; i++) {       b[i] = max(b[i - 1], a[i]);     }     int Q;     scanf( %d , &Q);     while (Q--) {       long long w, h;       cin >> w >> h;       cout << max(b[0], b[w - 1]) << endl;       b[0] = (max(b[0], b[w - 1]) + h);     }     return 0;   }   