N = input() dp = map(int,raw_input().split()) if N >= 3: dp[2] += dp[0] for i in xrange(3,N): dp[i] += max(dp[i-3],dp[i-2]) print max(dp[N-1],dp[N-2])