def max_taste(N: int, V: list) -> int: dp = [0] * N dp[0] = V[0] dp[1] = max(V[0], V[1]) for i in range(2, N): dp[i] = max(dp[i - 1], dp[i - 2] + V[i]) return dp[N - 1] N = int(input()) V = list(map(int, input().split())) print(max_taste(N, V))