import sequtils,strutils var n = parseInt readLine stdin vs = stdin.readLine.split.map parseInt dp = 0.repeat n dp[0] = vs[0] if n > 1: dp[1] = vs[1] if n > 2: dp[2] = vs[2] + vs[0] if n > 3: for i in 3..n-1: dp[i] = vs[i] + dp[i-2].max dp[i-3] echo max dp