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