#include using namespace std; #define int long long signed main(){ int n; cin >> n; int a[200010]; for(int i = 0;i < n;i++){ cin >> a[i]; } int b[200010] = {}; int ma = 0; for(int i = 0;i <= n-24;i++){ for(int j = 0;j < 24;j++){ b[i] += a[i+j]; } ma = max(ma, b[i]); } int q; cin >> q; for(int p = 0;p < q;p++){ int t, v; cin >> t >> v; t--; int d = v-a[t]; a[t] = v; for(int i = max(0ll, t-24);i <= min(t, n-23);i++){ b[i] += d; ma = max(ma, b[i]); } cout << ma << endl; } return 0; }