#include using namespace std; #define REP(i,m,n) for(int i=(m); i<(int)(n); i++) #define RREP(i,m,n) for(int i=(int)(n-1); i>=m; i--) #define rep(i,n) REP(i,0,n) #define rrep(i,n) RREP(i,0,n) #define all(a) (a).begin(),(a).end() #define rall(a) (a).rbegin(),(a).rend() #define aut(r,v) __typeof(v) r = (v) #define each(it,o) for(aut(it,(o).begin()); it!=(o).end(); ++it) #define reach(it,o) for(aut(it,(o).rbegin()); it!=(o).rend(); ++it) #define fi first #define se second #define debug(...) {cerr<<"[L"<<__LINE__<<"] "; _debug(__VA_ARGS__);} template ostream& operator<<(ostream& o, const pair& p) {return o<<"("<string join(const vector&v, string del=", ") {stringstream s;rep(i,v.size())s<ostream& operator<<(ostream& o, const vector&v) {if(v.size())o<<"["<ostream& operator<<(ostream& o, const vector >&vv) {int l=vv.size();if(l){o<ostream& operator<<(ostream& o, const set& st) {vector v(st.begin(),st.end());o<<"{ "<ostream& operator<<(ostream& o, const map& m) {each(p,m){o<<(p==m.begin()?"{ ":",\n ")<<*p<<(p==--m.end()?" }":"");}return o;} inline void _debug(){cerr< void _debug(const First& first, const Rest&... rest){cerr< pii; typedef vector vi; typedef vector vvi; typedef vector vl; typedef vector vvl; const double PI = (1*acos(0.0)); const double EPS = 1e-9; const ll INF = 0x3f3f3f3f; const ll INFL = 0x3f3f3f3f3f3f3f3fLL; const ll mod = 1e9 + 7; inline void finput(string filename) { freopen(filename.c_str(), "r", stdin); } int main(){ ios_base::sync_with_stdio(0); // finput("./input"); int n; cin >> n; vl A(2*n); rep(i,2*n) cin >> A[i]; vl s(n+1), rs(n+1); rep(i,n) s[i+1] = A[2*i] - A[2*i+1]; rep(i,n) rs[i] = -A[2*i] + A[2*i+1]; REP(i,1,n) s[i+1] += s[i]; RREP(i,1,n) rs[i-1] += rs[i]; ll ans = 0; rep(i,n) ans = max(ans, s[i] + rs[i]); cout << ans << endl; return 0; }