import java.util.ArrayDeque import kotlin.math.max fun main() { val builder = StringBuilder() val n = readInputLine().toInt() val vArr = readInputLine().split(" ").map { it.toInt() } // [sushi][取った:1 取らない:0] val dp = Array(n) { IntArray(2) } dp[0][1] = vArr[0] for (i in 1 until n) { dp[i][0] = max(dp[i - 1][0], dp[i - 1][1]) dp[i][1] = dp[i - 1][0] + vArr[i] } builder.appendln(max(dp[n - 1][0], dp[n - 1][1])) print(builder.toString()) } fun readInputLine(): String { return readLine()!! }