#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     vector<long long> vec;     vec.push_back(0LL);     for (int i = 0; i < n; i++) {       long long k;       cin >> k;       vec.push_back(k);     }     int m;     cin >> m;     vector<long long> v;     long long x = 0, y = 0;     for (int i = 0; i < m; i++) {       long long a, b;       cin >> a >> b;       if (vec[a] >= y) {         v.push_back(vec[a]);         y = vec[a] + b;       } else {         v.push_back(y);         y += b;       }     }     for (int i = 0; i < m; i++) cout << v[i] << endl;     return 0;   }   