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