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