import strutils, sequtils, algorithm, math var n = readLine(stdin).parseInt() vSeq = readLine(stdin).split(' ').map(parseInt) dp = newSeq[int](1002) dp[0] = vSeq[0] if n > 1: dp[1] = vSeq[1] if n > 2: dp[2] = dp[0] + vSeq[2] for i in countup(3, n - 1): dp[i] = max(dp[i - 2], dp[i - 3]) + vSeq[i] echo(dp[n - 1])