counter = int(input()) q_input = input().split() splited_input = [int(bb) for bb in q_input] ans_sum = 0 for i in range(int(counter / 2)): ans_sum += abs(splited_input[i] - splited_input[counter - 1 - i]) print(ans_sum)