output_description: Print the maximum possible sum of the absolute differences between the
  adjacent elements after arranging the given integers in a row in any order you
  like.
  
  * * *
input_description: Input is given from Standard Input in the following format:
  
      
      
      N
      A_1
      :
      A_N
attempt: #include <bits/stdc++.h>
  #define all(x) (x).begin(), (x).end()
  using namespace std;
  typedef long long ll;
  const int MOD = 1e9 + 7;
  
  int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
      cin >> a[i];
    }
    sort(all(a));
    vector<int> p, q;
    int ans = 0;
    for (int i = 0; i < n / 2; i++) {
      p.push_back(a[i]);
      p.push_back(a[n - i - 1]);
      q.push_back(a[n - i - 1]);
      q.push_back(a[i]);
    }
    int x = 0, y = 0;
    for (int i = 1; i < n; i++) {
      x += abs(p[i] - p[i - 1]);
      y += abs(q[i] - q[i - 1]);
    }
    cout << max(x, y) << endl;
    return 0;
  }
problem_description: Statement
  
  You are given N integers; the i-th of them is A_i. Find the maximum possible
  sum of the absolute differences between the adjacent elements after arranging
  these integers in a row in any order you like.
samples: [{"input": "5\n    6\n    8\n    1\n    2\n    3", "output": "21\n    \n\nWhen the integers are arranged as 3,8,1,6,2, the sum of the absolute\ndifferences between the adjacent elements is |3 - 8| + |8 - 1| + |1 - 6| + |6\n- 2| = 21. This is the maximum possible sum.\n\n* * *"}, {"input": "6\n    3\n    1\n    4\n    1\n    5\n    9", "output": "25\n    \n\n* * *"}, {"input": "3\n    5\n    5\n    1", "output": "8"}]