N = int(input()) value_list = list(map(lambda x: int(x), input().split(' '))) dp = [[0, 0] for _ in range(1001)] dp[0][0] = 0 dp[0][1] = value_list[0] dp[1][0] = value_list[0] dp[1][1] = value_list[1] for i in range(2, N): dp[i][0] = max(dp[i-1][1], dp[i-2][1]) dp[i][1] = max(dp[i-1][0] + value_list[i], dp[i-2][0] + value_list[i]) ans = max(dp[N-1][0], dp[N-1][1]) print(ans)