N = int(intput()) V = list(map(int, input().split())) DP = [0] * N for i in range(N): if i == 0: DP[0] = V[0] elif i == 1: DP[1] = max(DP[i-1], V[1]) else: DP[i] = max(DP[i-1], DP[i-2] + V[i]) print(DP[N-1])