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