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