n = int(input())
a = [int(i) for i in input().split()]

ans = sum([abs(a[i] - a[n-i-1]) for i in range(0, int(n/2))])
print(ans)