n=int(input()) l=list(map(int,input().split())) ans=0 for i in range(0,n//2): ans+=abs(l[i]-l[n-i-1]) print(ans)