// Problem: B - Products of Min-Max
// Contest: AtCoder - AtCoder Regular Contest 116
// URL: https://atcoder.jp/contests/arc116/tasks/arc116_b
// Memory Limit: 1024 MB
// Time Limit: 2000 ms
// 
// Powered by CP Editor (https://cpeditor.org)

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define vi vector<ll>
#define vll vector<ll> 
#define all(x) (x).begin() , (x).end()

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
#define rnd(x, y) uniform_ll_distribution<ll>(x, y)(rng)

void dbg(){
	cerr << endl;
}
template<typename Head , typename... Tail>
void dbg(Head h , Tail... t){
	cerr << h << " ";
	dbg(t...);
}

#ifdef EMBI_DEBUG
#define debug(...) cerr << "(" << #__VA_ARGS__  << "): ", dbg(__VA_ARGS__)
#else 
#define debug(...)
#endif

const ll max_n = 1e5 + 9;
const ll mod = 998244353;
const ll inf = 1e9;

typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
ll power(ll a , ll b)
{
    ll prod = 1;
    while(b)
    {
        if(b&1)
        prod = (prod*a)%mod;
        a = (a*a)%mod;
        b >>= 1;
    }
    return prod;
}
void solve(){
	ll n;
	cin >> n;
	
	vector<ll> a(n);
	for(ll &it : a) {
		cin >> it;
	}
	
	sort(all(a));
	
	ll sum = 0;
	
	for(ll i = 0 ; i < n ; i++) {
		sum += (a[i]*a[i])%mod;
		sum %= mod;
	}
	
	// for(ll  i = 0 ; i < n ; i++) {
		// for(ll j = i ; j >= 0 ; j--) {
			// sum += (a[i] * a[j] * power(2 , max(0ll , i - j - 1))) % mod;
			// sum %= mod;
		// }
	// }
	
	ll b[n];
	
	for(ll i = n - 2 , j = 0 ; i >= 0 ; j++ , i--) {
		b[i] = (a[i]*power(2,j))%mod;
	} 
	
	ll suff[n];
	suff[n-1] = a[n-1]%mod;
	for(ll i = n-2 ; i >= 0 ; i--) {
		suff[i] = (suff[i+1] + b[i]) % mod;
	}
	
	for(ll i = n-1 , j = 0 ; i >= 0 ; i-- , j++) {
		assert(suff[0]-suff[i]+mod >= 0);
		assert(power(power(2,j),mod-2) < mod);
		assert(((suff[0]-suff[i]+mod)%mod) < mod);
		sum += ((a[i]%mod) * ((((suff[0]-suff[i]+mod)%mod)*power(power(2,j),mod-2))%mod))%mod;
		sum %= mod;
	}
	
	cout << sum << "\n";
}
signed main(){
	ll t = 1;
	// cin >> t;
	for(ll i = 1 ; i <= t ; i++){
		solve();
	}
}

#include<cstdio>
#include<algorithm>
#include<cstring>

#define ll long long
#define fo(i,x,y) for(ll i=x;i<=y;i++)

using namespace std;
const ll mod=998244353;
const int N=2e5+10;
ll n,m,i,j,k,tot,ans,s,t,x,y,z,er;
ll a[N];
ll e[N];

void read(ll &a) {
	a=0; char c=getchar();
	while (c<'0'||c>'9') c=getchar();
	while (c>='0'&&c<='9') {a=a*10-48+c; c=getchar();}
	return;
}

ll ksm(ll i,ll j) {
	ll re=1;
	while (j>0) {
		if (j&1) re=re*i%mod;
		j/=2; i=i*i%mod;
	}
	return re;
}

int main() {
	e[0]=1; fo(i,1,N-1) e[i]=e[i-1]*2%mod;
	
	read(n);
	fo(i,1,n) read(a[i]);
	sort(a+1,a+n+1);
	
	s=0;
	fo(i,1,n) s=(s+a[i]*e[i-1])%mod;
	
	er=ksm(2,mod-2);
	ans=0;
	fo(i,1,n) {
		s=(s-a[i]+mod)*er%mod;
		
		ans=(ans+a[i]*s)%mod;
		ans=(ans+a[i]*a[i])%mod;
	}
	
	printf("%lld\n",ans);
}