n = int(input()) v = [int(x) for x in input().split()] res = 0 su = [0] * n for i in range(n): if i == 0: su[0] = v[0] elif i == 1: su[1] = v[1] elif i == 2: su[2] = su[0] + v[2] else: su[i] = v[i] + max(su[i - 2], su[i - 3]) res = max(su[i], res) print(res)