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