#include <bits/stdc++.h>
#pragma GCC optimize "-O3"
using namespace std;
const int MAXN = 120000;
int n;
int a[MAXN];
long long solve() {
  if (n == 1) return 0;
  sort(a, a + n);
  if (n % 2 == 0) {
    long long ans = 0;
    int k = n / 2;
    for (int i = 0; i < k - 1; ++i) ans -= 2 * a[i];
    ans -= a[k - 1];
    ans += a[k];
    for (int i = k + 1; i < n; ++i) ans += 2 * a[i];
    return ans;
  } else {
    long long ans = 0;
    int k = n / 2 + 1;
    for (int i = 0; i < k - 2; ++i) ans -= 2 * a[i];
    ans -= a[k - 1];
    ans -= a[k - 2];
    for (int i = k; i < n; ++i) ans += 2 * a[i];
    return ans;
  }
}
int main() {
  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  long long ans = solve();
  for (int i = 0; i < n; ++i) a[i] = -a[i];
  ans = max(ans, solve());
  cout << ans << "\n";
  return 0;
}
