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