#include #include #define rep(i, n) for(i = 0; i < n; i++) #define int long long using namespace std; int n; int a[200000]; int head[100001]; int tail[100001]; signed main() { int i; cin >> n; rep(i, 2 * n) cin >> a[i]; rep(i, n) { head[i + 1] = head[i] + a[2 * i] - a[2 * i + 1]; } rep(i, n) { tail[i + 1] = tail[i] + a[2 * n - 1 - 2 * i] - a[2 * n - 1 - 2 * i - 1]; } int ans = -1e+15; rep(i, n + 1) { int res = head[i] + tail[n - i]; ans = max(ans, res); } cout << ans << endl; return 0; }