n =int(input())
li = input().split()

c = 0
for i in range(1,n//2 + 1):
    
    if li[i-1] == li[-i]:
        continue
    else :
        c += abs(int(li[i-1]) - int(li[-i]))
   
   
print(c)