https://www.acmicpc.net/problem/2579
n = int(input())
dp = [[0]*(n+1) for _ in range(n+1)] #2*2 matrix
scores = [0] + [int(input()) for _ in range(n)]
# base case 설정
dp[1] = scores[1]
if n >= 2:
dp[2] = max(scores[1] + scores[2], scores[2])
if n >= 3:
dp[3] = max(scores[1] + scores[3], scores[2] + scores[3])
for i in range(4, n+1):
dp[i] = max(dp[i-2] + scores[i], dp[i-3] + scores[i-1] + scores[i])
print(dp[n])