#include <bits/stdc++.h>
using namespace std;
/* * * *   * * *   	* * * */
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
/* * * *   * * *   	* * * */
/* *
 *
 * Too many mind, no mind.
 *
 * */
const ll mod = 998244353;
ll add(ll a, ll b) { return a + b >= mod ? a + b - mod : a + b; }
ll sub(ll a, ll b) { return a >= b ? a - b : a - b + mod; }
ll mul(ll a, ll b) { return a * b % mod; }
ll powmod(ll b, ll e) {
	ll ans = 1;
	for (ll m = b; e; e >>= 1, m = mul(m, m)) 
		if (e & 1) ans = mul(ans, m);
	return ans;
}
int main(){
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int n; cin >> n;
	vector <ll> a(n);
	for (int i = 0; i < n; ++i) cin >> a[i];
	sort(a.begin(), a.end());
	ll sum = 0, p = 1, ans = 0, inv = powmod(2, mod - 2);
	for (int i = 0; i < n; ++i) {
		sum = add(sum, mul(a[i], p));
		p = mul(p, 2);
	}
	for (int i = 0; i < n; ++i) {
		sum = sub(sum, a[i]);
		sum = mul(sum, inv);
		ans = add(ans, mul(a[i], sum));
		ans = add(ans, mul(a[i], a[i]));
	}
	cout << ans << '\n';
	return 0;
}

#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)

using namespace std;
using LL = long long;
using P = pair<int,int>;
using vv = vector<vector<int>>;
const int INF = (int)1e9;
const LL LINF = (LL)1e18;

long long const mod = 998244353;
struct mint{
	long long val;
	mint(long long val = 0): val(val % mod) {}
	mint& operator += (const mint n){
		val += n.val;
		if(val >= mod) val -= mod;
		return *this;
	}
	mint& operator -= (const mint n){
		val -= n.val;
		if(val < 0) val += mod;
		return *this;
	}
	mint& operator *= (const mint n){
		val *= n.val;
		val %= mod;
		if(val < 0) val += mod;
		return *this;
	}
	mint operator + (const mint n) const{
		mint res(*this);
		return res += n;
	}
	mint operator - (const mint n) const{
		mint res(*this);
		return res -= n;
	}
	mint operator * (const mint n) const{
		mint res(*this);
		return res *= n;
	}
	mint pow(long long n) const{
		if(n == 0) return 1;
		mint m = pow(n >> 1);
		m *= m;
		if(n & 1) m *= *this;
		return m;
	}
	// mint division for prime mod
	mint inv() const{
		return pow(mod - 2);
	}
	mint& operator /= (const mint n){
		return (*this) *= n.inv();
	}
	mint operator / (const mint n) const{
		mint res(*this);
		return res /= n;
	}
};

int main(){
	int N;
	cin >> N;
	vector<LL> A(N);
	rep(i,N) cin >> A[i];
	if(N == 1){
		cout << A[0] * A[0] % mod << endl;
		return 0;
	}
	sort(A.begin(), A.end());
	mint ans = 0;
	vector<mint> sum(N-1);
	sum[N-2] = 1;
	for(int i = N - 3; i >= 0; i--) sum[i] = sum[i+1] * 2;
	mint tot = 0;
	rep(i,N-1) tot += sum[i] * A[i];
	for(int i = N - 1; i >= 0; i--){
		ans += A[i] * A[i];
		ans += tot * A[i];
		if(i == 0) break;
		tot -= A[i-1];
		tot /= 2;
	}
	cout << ans.val << endl;

	return 0;
}
