#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
#define md 998244353
#define N 200010
#define ll long long
ll a[N], ans = 0;
ll ksm(ll x, ll y) {
	if(y < 0) return 1;
	if(!y) return 1;
	ll l = ksm(x, y / 2);
	if(y % 2) return l * l % md * x % md;
	return l * l % md;
}
int main() {
	int n, i, j;
	scanf("%d", &n);
	for(i = 1; i <= n; i++) scanf("%d", &a[i]);
	sort(a + 1, a + n + 1);
	ll t = 0;
	for(j = 1; j <= n; j++) t = (t + a[j] * ksm(2, j - 2)) % md;
	for(i = 1; i <= n; i++) {
		ans = (ans + a[i] * t) % md;
		t = (((t - a[i] - a[i + 1]) * ksm(2, md - 2) + a[i + 1]) % md + md) % md;
	}
	printf("%lld\n", ans);
	return 0;
}
#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
//#define MOD 1000000007LL
#define MOD 998244353LL
#define doublecout(a) cout<<setprecision(16)<<a<<endl;
using vi = vector<ll>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける
using vvvi = vector<vvi>; // intの2次元の型に vvi という別名をつける
const ll llMAX=9223372036854775807LL; 
const ll llMIN=-9223372036854775808LL;

void myprint1D(vi &data)
{
  REP(i,data.size())
    cout<<data[i]<<" ";
  cout<<endl;
}

//配列を[y][x]で表示
void myprint2D_T(vvi &data)
{
  REP(i,data.size())
    myprint1D(data[i]);
}

//配列を[x][y]で表示
void myprint2D(vvi &data)
{
  ll l1=data.size();
  ll l2=data[0].size();
  REP(j,l2){
    REP(i,l1)
      cout<<data[i][j]<<" ";
    cout<<endl;
  }
}

//print(a,b...)って使い方
void print1(ll a){cout<<a<<endl;}
void print2(ll a,ll b){cout<<a<<" "<<b<<endl;}
void print3(ll a,ll b,ll c){cout<<a<<" "<<b<<" "<<c<<endl;}
void print4(ll a,ll b,ll c,ll d){cout<<a<<" "<<b<<" "<<c<<" "<<d<<endl;}
void print5(ll a,ll b,ll c,ll d,ll e){cout<<a<<" "<<b<<" "<<c<<" "<<d<<" "<<e<<endl;}


//moddivとnCkとgarner
ll gcd(ll a,ll b){
  ll r = a % b;
  while(r!=0LL){
    a = b;
    b = r;
    r = a % b;
  }
return b;
}

//c剰余下でaをbで割った値
ll moddiv(ll a,ll b,ll c){
	ll x0=c,x1=b,x2,n0=0LL,n1=1LL,n2,t=a%b,m,ans;
	if (t==0LL) return a/b;
		for(int i=0;i<900;i++){
      m=x0/x1;
      x2=x0-x1*m;
      n2=(n0-m*n1)%c;
      if (x2==1LL){
        ans=(n2+c)%c;
        break;
      }
      x0=x1;x1=x2;
      n0=n1;n1=n2;
    }
	return (a+((t*ans)%c)*b-t)/b;
}
//剰余の割ざん

//aのn乗 mod c
ll expmod(ll a,ll n,ll c){
  ll ans=1LL,aa=a,beki=n;
  for(int i=0;i<64;i++){
    if (beki%2==1LL) ans=ans*aa%c;
    aa=aa*aa%c;
    beki/=2LL;
    if (beki==0LL)break;
  }
  return ans;
}

//nCk
vi mulmod(500001);//0!,1!,2!,3!,4!,,,,
void first_nCk(){
  mulmod[0]=1LL;
  for(ll i=1;i<500001;i++){
    mulmod[i]=mulmod[i-1]*i%MOD;
  }
}
ll nCk(ll nn,ll kk){
  return moddiv(mulmod[nn],mulmod[kk]*mulmod[nn-kk]%MOD,MOD);
}
ll modinv(ll a,ll b){
  return moddiv(1,a%b,b);
}

//条件ar<a,br<b
ll garner(__int128_t a,__int128_t b,__int128_t ar,__int128_t br){
  if (gcd(a,b)==1){
    if (a==1){
      return br;
    }
    if (b==1){
      return ar;
    }
    
    __int128_t tmp=(br-ar)%b*modinv(a,b)%b;
    if (tmp<0)tmp+=b;
    return ar+tmp*a;
  }else{//299%200=99,299%300=299とかのとき
    //ありえない場合-1を出力
    __int128_t g=gcd(a,b);
    if (ar>br){
      __int128_t rr=ar-br;
      if (rr%g!=0){
        return -1;
      }
      __int128_t rrg=rr/g;
      __int128_t ret=garner(a/g,b/g,rrg,0);
      return ret*g+br;
    }else{
      __int128_t rr=br-ar;
      if (rr%g!=0){
        return -1;
      }
      __int128_t rrg=rr/g;
      __int128_t ret=garner(a/g,b/g,0,rrg);
      return ret*g+ar;
    }
  }
}
ll n,k,x,y;

int main(){
  ll ans=0;
  cin >> n;
  vi a(n),b(n),c(n);
  REP(i,n) cin>>a[i];
	sort(a.begin(), a.end());
	ll w=1;
	for(ll i=1;i<n;i++){
		b[i]=a[i]*w%MOD;
		w=w*2%MOD;
	}

	ll cc=0;
	for(ll i=1;i<n;i++){
		cc+=b[i];
	}
	cc%=MOD;


	for(ll i=0;i<n;i++){
		/*
		for(ll j=i+1;j<n;j++){
			//a[i]が最小a[j]が最大が何個あるか
			ll sc=a[i]*a[j]%MOD;
			sc=sc*expmod(2,j-i-1,MOD)%MOD;
			ans+=sc;

		}*/
		
		if (i==n-1)break;
		ans+=a[i]*cc%MOD;
		ans%=MOD;
		cc=cc-a[i+1]+MOD;
		cc%=MOD;
		cc=moddiv(cc,2,MOD);
	}

	for(ll i=0;i<n;i++){
		ans+=a[i]*a[i]%MOD;
		ans%=MOD;
	}
	/*
	最後に1この場合を足す
	*/

  cout<<ans<<endl;
  return 0;
}