// https://atcoder.jp/contests/abcXXX/tasks/abcXXX_x #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; using ll = long long; using ull = unsigned long long; using pll = pair; static const ll INF = 1001001001; static const ll LLINF = 1001001001001001001; #define REP(i, n) for(ll i = 0; i < (n); ++i) #define RANGE(i, m, n) for(ll i = (m); i <= (n); ++i) #define RRANGE(i, m, n) for(ll i = (m); i >= (n); --i) #define POSITIVE(x) (x)=((x) < 0) ? 0 : (x) ll power(ll x, ll y) { ll ret = 1; while(y-- > 0) ret *= x; return ret; } ll gcd(ll a, ll b) { assert(a >= 0); assert(b >= 0); if (b == 0) return a; return gcd(b, a % b); } ll iabs(ll x) { return x < 0 ? -x : x; } ll extgcd(ll a, ll b, ll& x, ll& y) { x = 1; y = 0; assert(a >= 0); assert(b >= 0); if (b == 0) return a; ll X, Y; auto d = extgcd(b, a % b, X, Y); x = Y; y = X - (a / b) * Y; return d; } int run(istream& in, ostream& out) { ll N; in >> N; vector v(2*N); ll a=0, b = 0; REP(i, N) { in >> v[2*i]; in >> v[2*i+1]; a+= v[2*i]; b+= v[2*i+1]; } ll total = a - b; ll ans = total; REP(i, N) { total -= 2*(v[2*i] - v[2*i+1]); ans = max(ans, iabs(total)); } out << ans << endl; return 0; } int main() { return run(cin, cout); }