n = int(input()) a = list(map(int, input().split())) def solve(d, i, w): if -1 < i - 2 < n: w += a[i - 2] if i >= n: return w return max(solve(i, i + 2, w), solve(i, i + 3, w)) print(solve(0, 0, 0))