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])