def main(): N = int(input()) V = list(map(int,input().split())) before = [0 , 0] dp = [0, 0] for i in V: dp[0] = max( before[0] , before[1] ) dp[1] = before[0] + i before = dp[:] print(dp) if __name__ == "__main__": main()