#include using namespace std; using ll = long long; int main() { cin.tie(nullptr); ios::sync_with_stdio(false); int m; cin >> m; int n = 2 * m; vector a(n); for (int i = 0; i < n; ++i) { cin >> a[i]; } if (n % 2 == 0) { vector L(n, 0), R(n + 1, 0); for (int i = 1; i < n; i += 2) { L[i] = a[i - 1] - a[i]; if (i > 1) L[i] += L[i - 2]; } for (int i = n - 2; i >= 0; --i) { R[i] = a[i + 1] - a[i]; if (i < n - 2) R[i] += R[i + 2]; } ll ans = R[0]; for (int i = 1; i < n; ++i) { ans = max(ans, L[i] + R[i + 1]); } cout << ans << "\n"; } else { vector L(n, 0), R(n + 2, 0); for (int i = 1; i < n; i += 2) { L[i] = a[i - 1] - a[i]; if (i > 1) L[i] += L[i - 2]; } for (int i = n - 2; i >= 0; --i) { R[i] = a[i + 1] - a[i]; if (i < n - 2) R[i] += R[i + 2]; } ll ans = a[0] + R[1]; for (int i = 1; i < n - 1; ++i) { ans = max(ans, L[i] + a[i] + R[i + 2]); } cout << ans << "\n"; } return 0; }