import copy n = int(input()) k = [int(x) for x in input().split()] def func(num,num_list): total = 0 a = [0,0] if num == 1: total = num_list[0] elif num == 2: total = max(num_list[0],num_list[1]) elif num == 0: total = 0 else: for i in range(2): a[i] += num_list[i] num2 = num - (i+2) ls = copy.copy(num_list) for _ in range(i+2): ls.pop(0) a[i] += func(num2,ls) total = max(a[0],a[1]) return total print(func(n,k))