#include <bits/stdc++.h>
#include <random>
using namespace std; typedef unsigned long long _ulong; typedef long long int lint; typedef pair<lint, lint> plint; typedef pair<double long, double long> pld;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define FOR(i, begin, end) for(lint i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(lint i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define endk '\n'
struct fast_ios { fast_ios() { cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(20); }; } fast_ios_;
template<class T> auto add = [](T a, T b) -> T { return a + b; };
template<class T> auto f_max = [](T a, T b) -> T { return max(a, b); };
template<class T> auto f_min = [](T a, T b) -> T { return min(a, b); };
template<class T> using V = vector<T>;
using Vl = V<lint>; using VVl = V<Vl>;
template< typename T > ostream& operator<<(ostream& os, const vector< T >& v) {
	for (int i = 0; i < (int)v.size(); i++) os << v[i] << (i + 1 != v.size() ? " " : "");
	return os;
}
template< typename T >istream& operator>>(istream& is, vector< T >& v) {
	for (T& in : v) is >> in;
	return is;
}
template<class T> bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
lint gcd(lint a, lint b) { if (b == 0) return a; else return gcd(b, a % b); }
lint ceil(lint a, lint b) { return (a + b - 1) / b; }
lint digit(lint a) { return (lint)log10(a); }
lint dist(plint a, plint b) { return abs(a.first - b.first) * abs(a.first - b.first) + abs(a.second - b.second) * abs(a.second - b.second); }
lint m_dist(plint a, plint b) { return abs(a.first - b.first) + abs(a.second - b.second); }
void Worshall_Floyd(VVl& g) { REP(k, SZ(g)) REP(i, SZ(g)) REP(j, SZ(g)) chmin(g[i][j], g[i][k] + g[k][j]); }
const lint MOD = 998244353, INF = 5e18;
lint dx[8] = { 1, 0, -1, 0, 1, -1, 1, -1 }, dy[8] = { 0, 1, 0, -1, -1, -1, 1, 1 };
void YN(bool flag) { cout << (flag ? "YES" : "NO") << endk; } void yn(bool flag) { cout << (flag ? "Yes" : "No") << endk; }
struct Edge {
	lint from, to;
	lint cost;
	Edge(lint u, lint v, lint c) {
		cost = c;
		from = u;
		to = v;
	}
	bool operator<(const Edge& e) const {
		return cost < e.cost;
	}
};
struct WeightedEdge {
	lint to;
	lint cost;
	WeightedEdge(lint v, lint c = 1) {
		to = v;
		cost = c;
	}
	bool operator<(const WeightedEdge& e) const {
		return cost < e.cost;
	}
};
using WeightedGraph = V<V<WeightedEdge>>;
typedef pair<plint, lint> tlint;
typedef pair<lint, tlint> qlint;
typedef pair<lint, string> valstring;

lint N;
int main() {
	cin >> N;
	Vl ar(N);
	cin >> ar;
	sort(ALL(ar));
	lint ans = 0;
	lint mn = 1 - N;
	REP(i, N) {
		ans += (ar[i] * mn);
		mn += 2;
	}
	cout << ans << endk;
}
#include <bits/stdc++.h>
#define MAX (ll)(1e6 + 7)
#define INF (ll)(1e18 + 7)
#define MOD (ll)(998244353)

using namespace std;
using ll = long long;
using cd = complex<double>;
using ul = unsigned long;

void f_io () {
 ios_base :: sync_with_stdio (false);
 cin.tie (nullptr);
}

ll f[MAX], t[MAX];

void up (ll ind, ll v) {
	for (ll i = ind; i < MAX; i += i & (-i))  {
		f[i] += v;
	}
}

ll qu (ll ind) {
	ll s = 0;
	for (ll i = ind; i; i -= i & (-i)) {
		s += f[i];
	}
	return s;
}

ll mult (ll a, ll b) {
	return (((a % MOD) * (b % MOD)) % MOD);
}

ll add (ll a, ll b) {
	b = (((b % MOD) + MOD) % MOD);
	return (a % MOD + b % MOD) % MOD;
}

ll pw (ll a, ll b) {
	ll r = 1;
	while (b) {
		if (b & 1) {
			r = mult (r, a);
		}
		b >>= 1;
		a = mult (a, a);
	}
	return r;
}

ll ncr (ll n , ll r) {
	if (r < 0 || n < 0 || n < r) return 0;
	return mult (f[n], pw (mult (f[n - r], f[r]), MOD -2 ));
}

void sieve () {
	for (ll i = 1; i < MAX; i++) {
		for (ll j = i; j < MAX; j += i) {
			f[j]++;
		}
	}
}

ll gc (ll a, ll b) {
	if (!a || !b) {
		return max (a, b);
	}
	ll r = a % b;
	while (r) {
		a = b;
		b = r;
		r = a % b;
	}
	return b;
}

int main () {
	f[0] = 1;
	for (ll i = 1; i < MAX; i++) {
		f[i] = mult (f[i - 1], i);
	}
	ll n, m, k, ans = 0;
	cin >> n >> m >> k;
	for (ll i = 1; i <= k; i++) {
		if (n == 1 || m == 1) {
			ans = add (ans, mult (add (pw (i, n), -pw (i - 1, n)), add (pw (k + 1 - i, m), -pw (k - i, m))));
		}
		else {
			ans = add (ans, mult (add (pw (i, n), -pw (i - 1, n)), pw (k + 1 - i, m - (n == 1 || m == 1))));
		}
	}
	cout << ans << "\n";
}
