N = int(input()) V = list(map(int, input().split())) dp = [0] * (N+1) for i in range(1, N+1): a = (dp[i-2] if i-2 >= 0 else 0) + V[i-1] b = (dp[i-3] if i-3 >= 0 else 0) + V[i-1] dp[i] = max(dp[i], a, b) print(dp[-1])