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