n = int(input()) v = list(map(int, input().split())) if n == 1: print(v[0]) else: a = [0] * (n+1) a[1] = v[0] for i in range(2, n+1): a[i] = max(a[i-1], v[i-1] + a[i-2]) print(a[n])