n = int(input()) vlst = list(map(int, input().split())) dp = [0 for _ in range(n)] if n == 1: print(vlst[0]) exit() dp[0] = vlst[0] dp[1] = max(vlst[1], vlst[0]) for i, v in enumerate(vlst[2:], 2): dp[i] = max(dp[i - 2] + v, dp[i - 1]) print(dp[-1])