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