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