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