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