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