n = int(input()) a = list(map(int, input().split())) end_o = 0 end_x = 0 for i in range(n): end_x, end_o = max(end_o, end_x), end_x + a[i] print(max(end_x, end_o))