N = int(input()) A = list(map(int, input().split())) DP = [0,-10**18] for i,a in enumerate(A): NDP = [DP[1]+a if DP[1]==-10**18 else max(DP[0],DP[1]+a) ,max(DP[1],DP[0]-a)] DP = NDP print(max(DP))