/* -*- coding: utf-8 -*- * * 999.cc: No.999 てん vs. ほむ - yukicoder */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; /* constant */ const int MAX_N = 100000; const long long LINF = 1LL << 62; /* typedef */ typedef long long ll; /* global variables */ ll ass[MAX_N + 1], bss[MAX_N + 1]; /* subroutines */ /* main */ int main() { int n; scanf("%d", &n); for (int i = 0; i < n; i++) { int a, b; scanf("%d%d", &a, &b); ass[i + 1] = ass[i] + a; bss[i + 1] = bss[i] + b; } ll maxd = -LINF; for (int i = 0; i <= n; i++) { ll h = ass[i] + (bss[n] - bss[i]); ll t = bss[i] + (ass[n] - ass[i]); ll d = h - t; if (maxd < d) maxd = d; } printf("%lld\n", maxd); return 0; }