#include using namespace std; int main(){ int N; cin >> N; vector A(N); for(int i=0; i> a >> b; A[i] = a-b; } int64_t sum = accumulate(A.begin(), A.end(), 0LL); int64_t ans = sum; for(int i=N-1; i>=0; i--){ sum -= 2*A[i]; ans = max(ans, sum); } cout << ans << endl; return 0; }