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