import sequtils import strutils import bitops import math import deques var n = stdin.readLine.parseInt var a = stdin.readLine.split.map parseInt var DP = newSeq[int](n+1) proc get[T](s:seq[T],index :int):T= if index < 0 or s.len <= index: return 0 return s[index] for i in 0..n: DP[i] = max(DP.get(i-2)+a.get(i),DP.get(i-1)) echo DP[n]