n = int(input()) vl = list(map(int, input().split())) max_v = vl.copy() for i in range(2, n): max_v[i] = max(max_v[i] + max_v[i-2], max_v[i-1]) print(max_v[-1])