#include int main(void) { int n, q, a[200001] = {}, sum_all[200002] = {}, sum_24[200002] = {}; scanf("%d", &n); for(int i = 0; i < n; i++) { scanf("%d", a + i); sum_all[i + 1] = sum_all[i] + a[i]; } for(int i = 24; i <= n; i++) { sum_24[i] = sum_all[i] - sum_all[i - 24]; } int max = 0; for(int j = 24; j <= n; j++) { if(max < sum_24[j]) { max = sum_24[j]; } } int max_tmp = 0; scanf("%d", &q); for(int i = 0; i < q; i++) { max_tmp = 0; int t, v; scanf("%d%d", &t, &v); int tmp = v - a[t - 1]; for(int j = t; j < t + 24; j++) { if((sum_24[j] += tmp) > max_tmp) { max_tmp = sum_24[j]; } } if(max_tmp > max) { max = max_tmp; } printf("%d\n", max); } return 0; }