N = int(input()) V = list(map(int, input().split())) inf = 10 ** 18 dp0 = [-inf] * (N + 1) dp1 = [-inf] * (N + 1) dp0[0] = 0 for i in range(N): dp0[i + 1] = max(dp0[i + 1], dp0[i], dp1[i]) dp1[i + 1] = max(dp1[i + 1], dp0[i] + V[i]) print(max(dp0[-1], dp1[-1]))