https://www.acmicpc.net/problem/2579
import java.util.*;
fun main() {
val s:Scanner=Scanner(System.`in`)
var n=s.nextInt()
var arr=Array<Int>(n+1) {0}
var num=Array<Int>(n+1) {0}
for(i in 1..n){
arr[i]=s.nextInt()
}
num[1]=arr[1]
if(n>1) num[2]=arr[1]+arr[2]
for(i in 3..n){
num[i]=Math.max(num[i-2],num[i-3]+arr[i-1])+arr[i]
}
print(num[n])
}