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