n = int(raw_input()) l = map(int, raw_input().split()) if n == 1: print l[0] else: ll = [l[0],max(l[0],l[1])] for i in range(2,n): ll.append(max(ll[i-1],ll[i-2]+l[i])) print ll[-1]