n = int(input()) a = list(map(int, input().split())) dp = [{} for x in range(n)] def solve(i, w): if -1 < i - 2 < n: w += a[i - 2] if i >= n: return w if dp[i].get(w): return dp[i][w] dp[i][w] = w return max(solve(i + 2, w), solve(i + 3, w)) print(solve(0, 0))