n = int(input()) a = list(map(int,input().split())) x = 0 y = 0 for i in range(n): if i == 0: x = a[i] else: z = max(x,y) y += a[i] x,y = y,z print(max(x,y))