#include using namespace std; using ll = long long; const int mod = 1e9 + 7; const int inf = (1 << 30) - 1; const ll infll = (1LL << 61) - 1; int N, Q, mx; int main() { cin >> N; vector a(N), rain(N - 23); for (int i = 0; i < N; i++) cin >> a[i]; for (int i = 0; i + 23 < N; i++) { for (int j = 0; j < 24; j++) { rain[i] += a[i + j]; } mx = max(mx, rain[i]); } cin >> Q; for (int i = 0; i < Q; i++) { int t, v; cin >> t >> v; t--; for (int j = max(0, t - 23); j <= min(t, N - 24); j++) { rain[j] += v - a[t]; mx = max(mx, rain[j]); } cout << mx << endl; } }