/** * author: shu8Cream * created: 05.02.2021 22:59:15 **/ #include using namespace std; #define rep(i,n) for (int i=0; i<(n); i++) #define all(x) (x).begin(), (x).end() using ll = long long; using P = pair; using vi = vector; using vvi = vector; int main() { cin.tie(nullptr); ios::sync_with_stdio(false); int n; cin >> n; vector c(n); rep(i,n) cin >> c[i]; sort(all(c)); ll ans = 0; if(n%2==0){ ll a = 0, b = 0; rep(i,n/2){ a+=c[i]; b+=c[i+n/2]; } ans=abs(abs(a)-abs(b)); }else{ ll a = 0, b = 0; rep(i,n/2+1){ a+=c[i]; b+=c[i+n/2]; } //cout << a << " " << b << endl; ll tmp = abs(a)-abs(b-c[n/2]); ans=max(tmp, abs(b)-abs(a-c[n/2])); //cout << abs(a)-abs(b-c[n/2]) << endl; //cout << abs(b)-abs(a-c[n/2]) << endl; } cout << ans << endl; }