#include <iostream>
using namespace std;
int main()
{
int n , G;
cin >> n;
int arr[n];
long long a = 0;
for (int i = 0; i < n; ++i)
{
cin >> arr[i];
}
int h = n / 2;
for (int i = 0; i < h; ++i)
{
G = abs(arr[n-1-i] - arr[i]);
a = G + a;
}
cout << a;
return 0;
}