from functools import lru_cache import sys sys.setrecursionlimit(2000) @lru_cache(maxsize=5000) def osusi(N, V): if N == 1: return V[0] pat = [0, 0, 0, 0, V[-2], V[-1]] if N - 2 >= 1: pat[0] = osusi(N - 2, V[:N - 2]) + V[-1] if N - 3 >= 1: pat[1] = osusi(N - 3, V[:N - 3]) + V[-1] pat[2] = osusi(N - 3, V[:N - 3]) + V[-2] if N - 4 >= 1: pat[3] = osusi(N - 4, V[:N - 4]) + V[-2] return max(pat) if __name__ == '__main__': N = int(input()) V_li = tuple(map(int, input().split())) print(osusi(N, V_li))