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