#include <iostream>
#include <vector>
#include <algorithm>

int main()
{
    using ll = long long;
    int N;
    std::cin >> N;

    if (N % 2 == 0) {
        ll a = 0, b = 0;
        for (int i = 0; i < N; ++i) {
            int tmp;
            std::cin >> tmp;
            if (i % 2 == 0) {
                a += tmp;
            } else {
                b += tmp;
            }
        }

        std::cout << std::max(a, b) << std::endl;
    } else {
        std::vector<ll> A(N);

        for (int i = 0; i < N; ++i) {
            std::cin >> A[i];
        }

        ll dp[200000][3] = {};
        dp[0][0] = A[0];
        dp[1][1] = A[1];
        dp[2][2] = A[2];

        for (int i = 3; i < N; ++i) {
            dp[i][0] = dp[i - 2][0] + A[i];
            dp[i][1] = std::max(dp[i - 2][1] + A[i], dp[i - 3][0] + A[i]);
            dp[i][2] = std::max(dp[i - 2][2] + A[i], dp[i - 3][1] + A[i]);
        }

        std::cout << dp[N - 1][2] << std::endl;
    }

    return 0;
}