n = int(input())
str_value = input()
arr = str_value.split()

count = 0

for index in range(0,int(n/2)):
    across = n - index - 1
    count += abs(int(arr[index])-int(arr[across]))

    
print (count)