#include using namespace std; int main() { int N; cin >> N; N *= 2; vector A(N); for (int i = 0; i < N; i++) cin >> A.at(i); long ans = 0; int M = N / 2 + 1; vector L(M), R(M); for (long i = 1, j = 0, sum = 0; i < M; i++) L.at(i) = sum += A.at(j) - A.at(j + 1), j += 2; reverse(A.begin(), A.end()); for (long i = 1, j = 0, sum = 0; i < M; i++) R.at(i) = sum += A.at(j) - A.at(j + 1), j += 2; reverse(R.begin(), R.end()); for (int i = 1; i + 1 < M; i++) ans = max(ans, L.at(i) + R.at(i)); cout << ans << "\n"; }