def sushi_max(V): s_max2 = 0 s_max = V[0] for i in range(1, len(V)): if (s_max2 + V[i]) > s_max: s_max, s_max2 = s_max2 + V[i], s_max else: s_max2 = s_max return s_max N = int(input()) sara = list(map(int, input().split())) print(sushi_max(sara))