def main(): N = int(input()) V = tuple(map(int, input().split())) if N < 3: print(max(V)) return vlen = len(V) ans = [] for i in (0, 1): v = V[i] while 1: if i + 2 < vlen: v1 = V[i+2] else: break if i + 3 < vlen: v2 = V[i+3] else: v2 = 0 if v1 > v2: v += v1 i += 2 else: v += v2 i += 3 ans.append(v) print(max(ans)) main()