N = int(input()) V = [int(i) for i in input().split()] dp ={} dp[N-1] = V[N-1] dp[N-2] = max(dp[N-2+1], V[N-2]) for i in reversed(range(N-2)): dp[i] = max(dp[i+1], dp[i+2] + V[i]) print(dp[0])