N = int(input()) V = [int(i) for i in input().split()] if N == 1: print(V[0]) exit(0) if N == 2: print(max(V[0], V[1])) exit(0) S = [V[0], V[1], V[2]] for i in range(3, N): tmp = max(S[i - 2], S[i - 3]) S.append(tmp + V[i]) print(max(S[N - 1], S[N - 2]))