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