#include using namespace std; #define all(x) (x).begin(), (x).end() #define rep(i, n) for (int i = 0; i < (n); i++) #define endl "\n" typedef long long ll; typedef pair pii; typedef pair pll; template ostream &operator<<(ostream &os, const vector &vec){os << "["; for (const auto &v : vec) {os << v << ","; } os << "]"; return os; } template ostream &operator<<(ostream &os, const pair &p) {os << "(" << p.first << ", " << p.second << ")"; return os;} void solve() { int N; cin >> N; vector A(N); for(int i = 0; i < N; i++) { cin >> A[i]; } int ma = 0; for(int i = 0; i <= N - 24; i++) { int sum = 0; for(int j = 0; j < 24; j++) { sum += A[i + j]; } ma = max(ma, sum); } int Q; cin >> Q; for(int q = 0; q < Q; q++) { int t, v; cin >> t >> v; t--; A[t] = v; for(int i = max(0, t - 23); i <= t && i + 23 < N; i++) { int sum = 0; for(int j = 0; j < 24; j++) { sum += A[i + j]; } ma = max(ma, sum); } cout << ma << endl; } } int main() { cin.tie(0); ios::sync_with_stdio(false); cout.setf(ios::fixed); cout.precision(16); solve(); return 0; }