import sys def check(a,b,x): if x < a or x > b: sys.exit() def choice(list,i): if len(list) <= i: return 0 pick = list[i] + choice(list,i+2) npick = choice(list,i+1) if pick > npick: return pick else: return npick N = int(input()) check(1,1000,N) list = input().split(' ') for i in range(0,len(list)): list[i] = int(list[i]) check(1,100,list[i]) print(choice(list,0))