size = int(input())

L = list(map(int, input().split()))

i = 0

numbers_of_ammo = 0

while i < len(L) // 2:

    numbers_of_ammo += abs(L[i] - L[len(L) - 1 - i])
    
    i += 1


print(numbers_of_ammo)