#include using namespace std; using ll = long long; template using Pa = pair; template using vec = vector; template using vvec = vector>; int main() { cin.tie(0); ios::sync_with_stdio(false); int N; cin >> N; vec A(2*N); for(int i=0;i<2*N;i++) cin >> A[i]; ll now = 0; for(int i=2*N-1;i>=0;i--){ if(i%2) now += A[i]; else now -= A[i]; } ll ans = now; for(int i=0;i<2*N;i+=2){ now += 2*A[i]; now -= 2*A[i+1]; ans = max(ans,now); } cout << ans << "\n"; }