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