N = int(input()) V = list(map(int, input().split())) max_d = [0] * N max_d[:2] = V[:2] for i in range(2, N): # 2個前までのおいしさを加味 max_d[i] = max_d[i-2] + V[i] # 3個前までのおいしさの方が凌駕してたらそっち採用 if (i >= 3) and (max_d[i] < max_d[i-3] + V[i]): max_d[i] = max_d[i-3] + V[i] print(max(max_d))