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