#include <bits/stdc++.h>
#define MOD 998244353
using namespace std;
 
int main() {
	int n;
	cin>>n;
	long long a[200010];
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	sort(a,a+n);
	long long x=a[0];
	long long pow=1;
	for(int i=1;i<n;i++){
		x=(x+pow*a[i])%MOD;
		pow=(pow*2)%MOD;
	}
	cerr<<x<<endl;
	long long sum=(x*a[0])%MOD;
	for(int i=1;i<n;i++){
		long long y=x-a[i-1]-a[i];
		if(y%2==0){
			y=y/2;
		}
		else{
			y=(y+MOD)/2;
		}
		y=(y+a[i])%MOD;
		sum=(sum+y*a[i])%MOD;
		x=y;
	}
	cout<<sum<<endl;
	for(int i=0;i<n;i++){
		cerr<<a[i]<<endl;
	}
	return 0;
}
#include <bits/stdc++.h>

using namespace std;

#define N 200000
#define mo 998244353

#define fo(i, x, y) for(int i = x; i <= y; i ++)
#define fd(i, x, y) for(int i = x; i >= y; i --)

void read(int &x) {
    char ch = getchar(); x = 0;
    while (ch < '0' || ch > '9') ch = getchar();
    while (ch >= '0' && ch <= '9') x = (x << 1) + (x << 3) + ch - 48, ch = getchar();
}

int a[N + 1], mi[N + 1];
int n;

int pw(int x, int k) {
    int res = 1;
    while (k) {
        if (k & 1) res = 1ll * x * res % mo;
        x = 1ll * x * x % mo;
        k >>= 1;
    }
    return res;
}

int main() {
    read(n);
    fo(i, 1, n) read(a[i]);
    int ans = 0, s = 0, inv = pw(2, mo - 2);
    mi[0] = 1;
    fo(i, 1, n) mi[i] = 1ll * mi[i - 1] * 2 % mo;
    sort(a + 1, a + 1 + n);
    fo(i, 2, n)
        s = (s + 1ll * a[i] * mi[i - 2] % mo) % mo;
    fo(i, 1, n - 1)
        ans = (ans + 1ll * a[i] * s % mo) % mo, s = 1ll * (s - a[i + 1] + mo) % mo * inv % mo;
    fo(i, 1, n) ans = (ans + 1ll * a[i] * a[i] % mo) % mo;
    printf("%d\n", ans);
    return 0;
}