n = int(input()) V = list(map(int,input().split())) dp = [[0,0] for _ in range(n+2)] for i in range(n): if i+1 < n: dp[i+2][1] = dp[i][0] + V[i+1] dp[i+1][1] = max(dp[i+1][1], dp[i][0] + V[i]) dp[i+1][0] = max(dp[i+1][0], dp[i][1]) print(max(dp[n]))