N = int(input()) vs = list(map(int, input().split())) dp = [0, 0] dp2 = [0, 0] for v in vs: dp2 = [0, 0] dp2[0] = max(dp[0], dp[1]) dp2[1] = dp[0] + v dp = dp2 print(max(dp))