n= int (input()) str = input() numberstr = str.split() number = [int(numbers) for numbers in numberstr ] j = n count = 0 for i in range( n // 2): j = n - 1 - i count += abs(number[i] - number[j]) print(count)