#include<bits/stdc++.h>
#include<tr1/unordered_map>
using namespace std;
#define int long long
int n;
int a[300000];
int dp[300000];
const int mod=998244353;
tr1::unordered_map<int,int>num,vis;
signed main()
{
    ios::sync_with_stdio(false);
    cin>>n;
    for(int i=1;i<=n;i++) cin>>a[i],num[a[i]]++;
    sort(a+1,a+1+n);
    for(int i=1;i<=n;i++)
    {
        dp[i]=dp[i-1]*2;
        dp[i]+=a[i];
        dp[i]%=mod;
    }int ans=0;
    for(int i=n;i>=1;i--)
    {
        ans+=a[i]*dp[i-1]%mod+a[i]*a[i]%mod;ans%=mod;
        //cout<<a[i]<<" "<<dp[i-1]<<endl;
    }
    cout<<ans<<endl;
}
#include<bits/stdc++.h>
#define L(i, j, k) for(int i = j, i##E = k; i <= i##E; i++)
#define R(i, j, k) for(int i = j, i##E = k; i >= i##E; i--)
#define ll long long
#define pii pair<int, int>
#define db double
#define x first
#define y second
#define ull unsigned long long
#define sz(a) ((int) (a).size())
using namespace std;
const int N = 1e6 + 7;
const int mod = 998244353, inv2 = (mod + 1) / 2; 
int n, a[N], pw[N], ipw[N], sum[N], ns;
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	cin >> n;
	pw[0] = ipw[0] = 1;
	L(i, 1, n + 1) pw[i] = (ll) pw[i - 1] * 2 % mod, ipw[i] = (ll) ipw[i - 1] * inv2 % mod;
	L(i, 1, n) cin >> a[i], (ns += (ll) a[i] * a[i] % mod) %= mod;
	sort(a + 1, a + n + 1);
	R(i, n, 1) sum[i] = (sum[i + 1] + (ll) a[i] * pw[i] % mod) % mod;
	L(i, 1, n) (ns += (ll) a[i] * sum[i + 1] % mod * ipw[i + 1] % mod) %= mod;
	cout << ns << "\n";
	return 0;
}