#include using namespace std; using lint = long long; template using V = vector; template using VV = V< V >; int main() { cin.tie(nullptr); ios::sync_with_stdio(false); int n; cin >> n; V<> a(n); for (auto&& e : a) cin >> e; int q; cin >> q; int res = 0; for (int i = 0; i + 24 <= n; ++i) { res = max(res, accumulate(begin(a) + i, begin(a) + i + 24, 0)); } while (q--) { int t, x; cin >> t >> x, --t; a[t] = x; for (int i = max(t - 23, 0); i <= min(t, n - 24); ++i) { res = max(res, accumulate(begin(a) + i, begin(a) + i + 24, 0)); } cout << res << '\n'; } }