n=int(input())
obstacle = list(map(int, input().split()))
shot = 0
print(obstacle)

for i in range(int(n/2)):
    d = abs(obstacle[i] - obstacle[n-i-1])
    shot += d
print(shot)