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