#include #include #include #include using namespace std; int n; int main() { cin >> n; vectorarr(n,0); for (int i = 0; i < n; ++i) { cin >> arr[i]; } sort(arr.begin(), arr.end()); long long x =0, y=0; int l, r; for ( l = 0, r = n - 1; l < r; l++, r--) { x += arr[r]; y += -arr[l]; } if (l == r) x += arr[r]; cout << x - y << endl; return 0; }