import strutils,sequtils,math let n: int = stdin.readline.parseint let v: seq[int] = stdin.readline.split.map(parseint) if n != 1: var dp: seq[int] # initialization dp.add(v[0]) if v[0] < v[1]: dp.add(v[1]) else: dp.add(v[0]) for i in 2.. dp[i-1]: dp.add(dp[i-2] + v[i]) else: dp.add(dp[i-1]) echo dp[n-1] else: echo v[0]