while True:
    try:
        a = int(input())
        b = list(map(int,input().split()))
        dp = [0]*a
        for i in range(a):
            if i <= 1:
                dp[i] = max(b[:i+1])
            else:
                dp[i] = max(dp[i-2]+b[i],dp[i-1])
        print(max(dp))
    except:
        break