#include using namespace std; const long long INF = 1LL<<60; long long calc(vector &c, int a, int b) { int n = c.size(); int av = !a ? 0 : n-1; int ad = !a ? 1 : -1; int bv = !b ? 0 : n-1; int bd = !b ? 1 : -1; vector used(n); long long x = 0; long long y = 0; for (int t = 0; t < n; t++) { if (t % 2 == 0) { while (used[av]) av += ad; x += c[av]; used[av] = true; } else { while (used[bv]) bv += bd; y += c[bv]; used[bv] = true; } } return abs(x) - abs(y); } int main() { ios_base::sync_with_stdio(0); cin.tie(0); int n; cin >> n; vector c(n); for (int i = 0; i < n; i++) cin >> c[i]; sort(c.begin(), c.end()); long long ret = -INF; for (int i = 0; i < 2; i++) { long long v = INF; for (int j = 0; j < 2; j++) { v = min(v, calc(c, i, j)); } ret = max(ret, v); } cout << ret << endl; return 0; }