n = int(input()) dp = [-10**9, -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))