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