import Foundation
let main: () = {
    let N = nextInt()
    let A = listOfInt()
    var dp = Array(N) { [0, 0] }
    dp[1][1] = A[1]
    dp[1][0] = A[0]
    for n in 2 ..< N {
        if (n.isEven) {
            if (n < 3) {
                dp[n][1] = A[n] + [dp[n - 2][1], dp[n - 2][0]].max()!
                dp[n][0] = [dp[n - 1][1], dp[n - 1][0]].max()!
            } else {
                dp[n][1] = A[n] + [dp[n - 3][1], dp[n - 3][0], dp[n - 2][1], dp[n - 2][0]].max()!
                dp[n][0] = [dp[n - 1][1], dp[n - 1][0], A[n - 2] + dp[n - 3][0]].max()!
            }
        } else {
            dp[n][1] = A[n] + [dp[n - 2][1], dp[n - 2][0], dp[n - 1][0]].max()!
            dp[n][0] = A[n - 1] + dp[n - 2][0]
        }
    }
    let ans = dp.last!.max()!
    print(ans)
}()

@inlinable func next() -> String { readLine()! }
@inlinable func nextInt() -> Int { Int(next())! }
@inlinable func listOfString() -> [String] { next().split(separator: " ").map(String.init) }
@inlinable func listOfInt() -> [Int] { listOfString().map { Int($0)! } }
extension Int {
    var isEven: Bool { self.isMultiple(of: 2) }
}

extension Array {
    init(_ size: Int, _ initValue: (() -> Element)) {
        self = [Element]()
        for _ in 0 ..< size {
            let value = initValue()
            self.append(value)
        }
    }
}
