#include <iostream>
#include <string>

using namespace std;


int main()
{

    int n;
    cin >> n;
    int a[n];
    for (int i = 0; i < n ; i++)
    {
      cin >> a[i];
    }
    int b = 0;
    for (int i = 0; i < n/2; i++)
    {
      b += abs(a[i] - a[n-1-i]);
    }
    cout << b;
  
    return 0;
 }