func main() {
  let n = Int(readLine()!)!
  let a = readLine()!.split(separator: " ").map { Int($0)! }

  var cEven = 0
  var dp = [Int: Int]()
  dp[-1] = 0

  for i in 0..<n {
    if i == 0 {
      cEven += a[i]
      dp[i] = 0
      continue
    }
    if i % 2 == 0 {
      cEven += a[i]
      dp[i] = max(dp[i-1]!, dp[i-2]! + a[i])
    }
    else {
      dp[i] = max(dp[i-2]! + a[i], cEven)
    }
  }

  print(dp[n-1]!)
}

main()
