N = int(input()) A = list(map(int, input().split())) A.insert(0,0) X = 0 Y = 0 MaxT = [0, A[1]] MaxD = [0, 0, A[1]] if N == 1: print(A[1]) exit() else: MaxT.append(A[2]) for i in range (3, N+1): X = max(MaxT[i-2], MaxD[i-2]) + A[i] Y = max(MaxD[i-2] + A[i-1], MaxT[i-2]) MaxT.append(X) MaxD.append(Y) if MaxT[N] >= MaxD[N]: print(MaxT[N]) else: print(MaxD[N])