#include <bits/stdc++.h>

using namespace std;

typedef long long   ll;

const int N = int(2e5) + 10;
ll a[N];
const ll mod = ll(998244353LL);

// ll sum(int m, int n){
//     ll mx = -1;
//     ll mn = -1;
//     for(int j = 0 ; j < n ; j++){
//         int e = 1 << j;

//         if(m & e){
//             if(mx == -1){
//                 mx = a[j];
//                 mn = a[j];
//             }else{
//                 mx = max(mx, a[j]);
//                 mn = min(mn, a[j]);
//             }
//         }
//     }

//     return (mx * mn) % mod;
// }

int main(){
    int n;

    scanf("%d", &n);

    for(int i = 0 ; i < n ; i++){
        scanf("%lld", &a[i]);
    }

    // ll tmp = 0LL;

    // for(int m = 1 ; m < (1 << n) ; m++){
    //     tmp = (tmp + sum(m, n)) % mod;
    // }

    // printf("tmp = %lld\n", tmp);

    sort(a, a + n);

    ll sum = 0LL;
    ll ans = 0LL;

    for(int i = 0 ; i < n ; i++){
        // printf("%lld adds %lld\n", a[i], ((a[i] * sum) % mod + a[i] * a[i]));
        ans = (ans + ((a[i] * sum) % mod + a[i] * a[i]) % mod) % mod;
        sum = (sum * 2LL + a[i]) % mod;
    }

    printf("%lld\n", ans);

    return 0;
}
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define pb push_back
#define pii pair <int, int>
#define vi vector<int>

#define FOR(i, a, b) for (int i=a; i<b; i++)
#define FORd(i, a, b) for (int i=a-1; i>=b; i--)
#define F0Rd(i, a) for (int i=a-1; i>=0; i--)
#define F0R(i, a) for (int i=0; i<a; i++)
 
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
 
const int MOD = 998244353;
long double PI = 4*atan(1);
/*std::cout << std::fixed << std::setprecision(2);
ll po (ll b, ll p) return !p?1:po(b*b%MOD,p/2)*(p&1?b:1)%MOD;
ll inv (ll b) { return po(b,MOD-2); }*/

ll n,a[200001],dp[200001],ans,cur;

void calc() {
	dp[n-1] = 0LL;
	if(n==1) return;
	dp[n-2] = a[n-1];
	if(n==2) return;
	F0Rd(i,n-2) {
		dp[i] = a[i+1]+ (2LL*dp[i+1]);
		dp[i] %= MOD;
	}
	//F0R(i,n) cout << dp[i] << " ";
}

void solve() {
	cin >> n;
	F0R(i,n) cin >> a[i];
	sort(a,a+n);
	calc();
	F0R(i,n) {
		cur = (a[i]*a[i])%MOD;
		ans = (ans+cur)%MOD;
		cur = (a[i]*dp[i])%MOD;
		ans = (ans+cur)%MOD;
		//cout << ans << " ";
	}
	cout << ans;
}

int main()
{
    ios::sync_with_stdio(0), cin.tie(0);
    int test_cases = 1;
    //cin >> test_cases;
    F0R(i,test_cases) {
    	solve();
    	//init();
    }
    return 0;
}