# No.45 回転寿司 def main(): N = int(input()) A = tuple(map(int, input().split())) # dp[take or not][i] := optimum value when taking i-th sushi or not dp = [[0] * (N + 1) for _ in range(2)] for i in range(1, N + 1): dp[0][i] = dp[1][i - 1] + A[i - 1] dp[1][i] = max(dp[0][i - 1], dp[1][i - 1]) print(max(dp[0][-1], dp[1][-1])) if __name__ == "__main__": main()