n = int(input()) dp = [-2*10**9, -2*10**9] for a in map(int, input().split()): dp = [max(dp[0], dp[1] + a), max(dp[1], dp[0] - a, -a)] print(max(dp))