n = int(input()) V = list(map(int,input().split())) dp = [0]*2 for v in V: ndp = [0]*2 ndp[0] = max(dp[1],dp[0]) ndp[1] = dp[0]+v dp = ndp print(max(dp))