length = input()

numbers = [int(x) for x in input().split(' ')]


answer = 0
for i in range(len(numbers)):
    if (i + 1 < int(len(numbers) / 2)):
        break;

    if (numbers[i] != numbers[len(numbers) - 1 - i]):
        answer += abs(numbers[i] - numbers[len(numbers) - 1 - i])
        """ print(f"current answer: {answer}, current number: {numbers[i]} vs {numbers[len(numbers) - 1 - i]}") """

print(answer)