//#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector")
#include <bits/stdc++.h>
#include<set>
#include <array>
using namespace std;
#define ll long long
#define endl '\n'
#define mod 998244353
#define pb push_back
#define ff first
#define ss second
#define con continue
#define ub upper_bound
#define lb lower_bound

#define si(x) int(x.size())
#define sum_all(a)     ( accumulate ((a).begin(), (a).end(), 0ll))
#define mine(a)    (*min_element((a).begin(), (a).end()))
#define maxe(a)    (*max_element((a).begin(), (a).end()))
#define mini(a)    ( min_element((a).begin(), (a).end()) - (a).begin())
#define maxi(a)    ( max_element((a).begin(), (a).end()) - (a).begin())
#define lowb(a, x) ( lower_bound((a).begin(), (a).end(), (x)) - (a).begin())
#define uppb(a, x) ( upper_bound((a).begin(), (a).end(), (x)) - (a).begin())
const double pi = 2 * acos(0.0);
const int dx[] = { -1, 0, 1, 0 };
const int dy[] = { 0, -1, 0, 1 };

const int dx8[] = { -1, 0, 1, 0,1,1,-1,-1 };
const int dy8[] = { 0, -1, 0, 1,1,-1,1,-1 };

ll min(ll a,ll b)
{
    if(a<b)return a;
    return b; 
}
ll max(ll a,ll b)
{
    if(a>b)return a;
    return b; 
}
ll ceil1(ll a,ll b)
{
    return(a+b-1)/b;
}
void read(vector<ll> & arr)
{
  for(ll i=0;i<si(arr);i++)
    cin >> arr[i];

}

void read_graph(vector<vector<ll>>& g, ll m)
{
  while(m--)
  {
    ll x,y; cin >> x>> y ;
    x--,y--; 
    g[x].pb(y);
    g[y].pb(x);
  }
}
ll modmul(ll x, ll y, ll m=mod)
{
    if (y==0) return 0;
    ll a = modmul(x, y / 2, m) % m; 
    a = (a + a) % m;
    if (y % 2 != 0)
    {
        a = (a + x) % m;
    }
    return a;
}
 ll power(ll a, ll b, ll m)
{
    if (b == 1) return a;
    ll x = power(a, b / 2, m);
    x *= x;
    x %= m;
    if (b % 2 == 1)
    {
        x *= a;
        x %= m;
    }
    return x;
}
void solve()
{
int n;
cin >> n ;
vector<ll> arr(n);
for(int i=0;i<n;i++)
cin >> arr[i]; 

sort(arr.begin(),arr.end()); 
// for(ll i=0;i<n;i++) cout << arr[i]  << " " ;
  // cout << endl ;
vector<ll> suff(n);
vector<ll> pw(n+1);
pw[0]=1;
for(ll i=1;i<=n;i++) 
{
   pw[i]=pw[i-1]*2;
   pw[i]%=mod; 
}

for(ll i=0;i<n;i++)
{
   suff[i]= modmul(arr[i],pw[i],mod); 
   suff[i]%=mod; 
}
for(ll i=n-2;i>=0;i--)
{
  suff[i] +=suff[i+1];
  suff[i]%=mod; 
}
ll inv_2= power(2,mod-2,mod);
ll base=inv_2;
// ll k =853983 *853983 ;
ll ans=0 ;

for(ll i=0;i<n;i++)
{
   ans+=(modmul(arr[i],arr[i]))%mod;
   ans%=mod; 
}
for(ll i=0;i<n-1;i++)
{
  ll x ; 
  x= modmul(suff[i+1],inv_2);
  x=modmul(arr[i],x);  
  ans+=x;
  ans%=mod; 
  inv_2= modmul(inv_2,base);
}
cout << ans <<endl; 

}


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
   // int t; cin >> t; while (t--)
    solve();

}

#include<bits/stdc++.h>
#define re register
#define int long long
using namespace std;
inline int read(){
	re int t=0;re char v=getchar();
	while(v<'0')v=getchar();
	while(v>='0')t=(t<<3)+(t<<1)+v-48,v=getchar();
	return t;
}
const int M=998244353;
inline int ksm(re int x,re int y){
	re int s=1;
	while(y){
		if(y&1)s=1ll*s*x%M;
		x=1ll*x*x%M,y>>=1;
	}
	return s;
}
int n,m,a[1000002],ans,b[1000002],sum;
char s[1000002];
signed main(){
	n=read();
	for(re int i=1;i<=n;++i)a[i]=read();
	sort(a+1,a+n+1);
	for(re int i=1;i<=n;++i){
		ans=(ans+a[i]*sum)%M;
		ans=(ans+a[i]*a[i])%M;
		sum=(sum+sum)%M;
		sum=(sum+a[i])%M;
	}
	printf("%lld",ans);
}
