#include "bits/stdc++.h" using namespace std; typedef long long int ll; typedef pair pi; typedef pair, ll > pii; vector vec; vector > vec2; ll MOD = 1000000007; ll INF = 1145141919454519; int main(){ ll N; cin >> N; N *= 2; vector v; for(ll i = 0; i < N; i++){ ll t; cin >> t; v.push_back(t); } ll ans = 0; ll sumA = 0; ll sumB = 0; for(ll i = 0; i < N; i++){ if(i % 2 == 1){ sumA += v[i]; }else{ sumB += v[i]; } } for(ll i = 0; i < N - 1; i+=2){ sumA = sumA + v[i] - v[i+1]; sumB = sumB - v[i] + v[i+1]; ll tmp = sumA - sumB; ans = max(ans, tmp); } cout << ans << endl; }