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

  var cEven = 0
  var dp = Array(repeating: 0, count: n)
  
  // initial conditions
  cEven += a[0]
  dp[0] = 0
  dp[1] = max(a[1], cEven)

  for i in 2..<n {
    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()
