#include using namespace std::literals::string_literals; using i64 = long long; using std::cout; using std::endl; using std::cin; template std::vector make_v(size_t a){return std::vector(a);} template auto make_v(size_t a,Ts... ts){ return std::vector(ts...))>(a,make_v(ts...)); } int main() { int n; scanf("%d", &n); std::vector a(n); for(int i = 0; i < n; i++) scanf("%d", &a[i]); const int day = 24; int ma = -1; for(int i = 0; i < n - day + 1; i++) { int sum = 0; for(int j = 0; j < day; j++) sum += a[i + j]; ma = std::max(ma, sum); } int q; scanf("%d", &q); while(q--) { int p, x; scanf("%d%d", &p, &x); p--; a[p] = x; for(int i = std::max(0, p - day + 1); i <= std::min(p, n - day); i++) { int sum = 0; for(int j = 0; j < day; j++) sum += a[i + j]; ma = std::max(ma, sum); } printf("%d\n", ma); } return 0; }