n = int(input()) v = list(map(int, input().split())) p, q = 0, 0 for sushi in v: p, q = sushi + q, max(p, q) print(max(p, q))