import bisect,collections,itertools,math,functools,heapq import sys #sys.setrecursionlimit(10**6) def I(): return int(sys.stdin.readline().rstrip()) def IN(): return int(input()) def LIN(): return list(map(int, input().split())) def LI(): return list(map(int,sys.stdin.readline().rstrip().split())) def LF(): return list(map(float,sys.stdin.readline().rstrip().split())) def SI(): return sys.stdin.readline().rstrip() def LS(): return list(sys.stdin.readline().rstrip().split()) """ 方針 dp """ N=I() V=LI() dp = [[0,0] for _ in range(N+1)] for i in range(N): v = V[i] dp[i+1][0] = max(dp[i][1] + v, dp[i][0]) dp[i+1][1] = max(dp[i][0], dp[i][1]) print(max(dp[N]))