#include using namespace std; using ll = long long; using P = pair; #define rep(i,n) for(int i=0;i> n; vector a(2*n); rep(i,2*n) cin >> a[i]; vector l,r; l.push_back(0l); r.push_back(0l); for (int i=0;i<2*n;i+=2) l.push_back(l.back() + (a[i]-a[i+1])); for (int i=2*n-1;i>=0;i-=2) r.push_back(r.back() + (a[i]-a[i-1])); reverse(r.begin(),r.end()); ll ans = 0l; rep(i,l.size()){ ans = max(ans,l[i]+r[i]); } cout << ans << endl; return 0; }