import Foundation let n = Int(readLine()!)! let values = readLine()!.split(separator:" ").map { Int($0)! } if n == 1 { print(values[0]) exit(0) } var dp = Array(repeating: 0, count: 3) dp[(n - 1) % 3] = values[n - 1]; dp[(n - 2) % 3] = Swift.max(values[n - 2], values[n - 1]) for i in (0 ..< n-2).reversed() { dp[i % 3] = Swift.max(values[i] + dp[(i + 2) % 3], dp[(i + 1) % 3]) } print(dp[0])