# https://hotcodes.org/problem/1 length = int(input()) nums = list(map(int,input().split())) count = 0 for index in range(length // 2) : count += abs(nums[index] - nums[length - index - 1]) print(count)