n = int(input()) v = list(map(int, input().split())) routes = [[1]] flag = True ans = [] while flag: flag = False r = [] for route in routes: if route == []: continue if route[-1] < n: r.append(route + [route[-1] + 2]) r.append(route[:-1] + [route[-1] + 1]) flag = True elif route[-1] == n: ans.append(route) ans.append(route[:-1]) else: ans.append(route[:-1]) if flag == True: routes = r else: score = [] for a in ans: s = 0 for i in a: s += v[i-1] score.append(s) print(max(score))