#include <bits/stdc++.h>
using namespace std;
#define int long long
#define M 998244353
int binary_expo(int a,int b)
{
    int res=1;
    while(b>0)
    {
        if(b&1>0)
        {
            res=(((res%M)*(a%M))%M);
        }
        b=b>>1;
        a=(((a%M)*(a%M))%M);
    }
    return res;
}
int inv(int a,int b)
{
    a=(((a%M)*(binary_expo(b,M-2)))%M);
    return a;
}
int32_t main() 
{
    int t=1;
    //cin>>t;
    while(t--)
    {
        int n;cin>>n;
        vector<int> a(n,0);
        for(int i=0;i<n;i++)
        {
            cin>>a[i];
        }
        sort(a.begin(),a.end());
        int p=0;
        int i=n-2;
        int s=0;
        while(i>=0)
        {
            s+=((a[i]*(binary_expo(2,p)))%M);
            s%=M;
            p++;
            i--;
        }
        int c=0;
        for(int i=n-1;i>0;i--)
        {
            int k=((s*a[i])%M);
            c+=k;
            c%=M;
            s=((s-a[i-1]+M)%M);
            s=(inv(s,(int)2)%M);
            s%=M;
        }
        for(int i=0;i<n;i++)
        {
            c+=((a[i]*a[i])%M);
            c%=M;
        }
        cout<<c<<endl;

    }
    return 0;
}

#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <string>
#include <map>
#include <cmath>
#include <tuple>

#define ll long long
#define MAX 1000000007
#define mod % 998244353
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;

vector<ll> beki;

int main(){
  ll n;
  cin >> n;
  beki.push_back(1);
  rep(i,n+3){
    beki.push_back((beki[i]*2)mod);
  }
  vector<ll> a(n);
  rep(i,n){
    cin >> a[i];
  }
  sort(a.begin(),a.end());
  ll ans = 0;
  ll sum = 0;
  rep(i,n){
    ans = (ans+a[i]*sum) mod;
    sum = (sum*2+a[i]) mod;
    ans = (ans + (a[i]*a[i]))mod;
  }
  cout << ans << endl;
  
  return 0;
}