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