#include <iostream>
using namespace std;
int main()
{
   int n;
   cin >> n;
   int arr[n];
   int shot = 0;

   for ( int i = 0 ; i < n ; i ++ )
   {
      cin >> arr[i];
   }
   
   int b = n - 1;
   for ( int i = 0 ; i < n / 2 ; i ++ )
   {
      if ( arr[i] != arr[b] )
      {
        int x = arr[i];
        int y = arr[b];
        shot =+ abs( x - y );
      }
      
      b --;
   }

   cout << shot;


   return 0;
}