from enum import IntEnum, auto # ステート遷移 class E(IntEnum): EAT = 0 NOT_EAT = auto() def nexts(self): match self: case E.EAT: return [E.NOT_EAT] case E.NOT_EAT: return [E.EAT, E.NOT_EAT] assert False def cost(self, x: int) -> int: match self: case E.EAT: return x case E.NOT_EAT: return 0 assert False N = int(input()) V = list(map(int, input().split())) dp = [[0] * len(E) for _ in range(N+1)] for i, v in enumerate(V): for fm in E: for to in fm.nexts(): dp[i+1][to] = max(dp[i+1][to], dp[i][fm] + to.cost(v)) ans = max(dp[N]) print(ans)