fun main() { val N: Int = readLine()!!.toInt() var V: IntArray = readLine()!!.split(" ").map(String::toInt).toIntArray() fun getPlusValue(targetIndex: Int): Int { return if (targetIndex < V.size) V[targetIndex] else 0 } for (i in (V.size - 1 downTo 0)) { val plus2 = getPlusValue(i + 2) val plus3 = getPlusValue(i + 3) V[i] += if (plus2 > plus3) plus2 else plus3 } println(V.max()) }