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