n = int(input()) sq = list(map(int,input().split())) m1 = 0 m2 = 0 m3 = sq[0] cnt = 1 while cnt < n: m4 = max([sq[cnt]+m2, sq[cnt]+m1]) m1,m2,m3 = m2,m3,m4 cnt += 1 print(max([m1,m2,m3]))