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