#include<bits/stdc++.h>
using namespace std;
#define int long long 
int read(){
    int x = 0, f = 1; char ch;
    while(!isdigit(ch = getchar())) (ch == '-') && (f = -1);
    for(x = ch ^ 48 ; isdigit(ch = getchar()) ; x = (x << 3) + (x << 1) + (ch ^ 48));
    return x * f;
}
const int N = 1e6 + 9, p = 998244353;
int a[N],s[N];
int my_pow(int a,int b){
    int ans = 1, base = a;
    while(b){
        if(b & 1) ans = ans * base % p;
        base = base * base % p;
        b >>= 1;
    } return ans;
}
signed main(){
    int n = read(), ans = 0;
    for(int i = 1 ; i <= n ; i ++) a[i] = read();
    sort(a + 1,a + n + 1);
    for(int i = 1 ; i <= n ; i ++) s[i] = my_pow(2,i) * a[i] % p;
    for(int i = n ; i >= 1 ; i --) s[i] += s[i + 1], s[i] %= p;
    for(int i = 1 ; i <= n ; i ++){
        ans += a[i] * my_pow(my_pow(2,i + 1),p - 2) % p * s[i + 1] % p;
        ans += a[i] * a[i] % p, ans %= p;
    } cout<<ans<<"\n";
    return 0;
}
/* dont stick to an approach */
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <algorithm>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <vector>
#include <numeric>
#include <cstdlib>
#include <chrono>

using namespace std;
using namespace std::chrono;

typedef long long ll;
typedef unsigned long long int ull;
typedef long double ldb;

#define PB push_back

#define For(i, n) for (ll i = 0; i < n; i++)

#define trav(a,x) for (auto& a : x)

#define PYES cout<<"YES\n"
#define PNO cout<<"NO\n"
#define PYes cout<<"Yes\n"
#define PNo cout<<"No\n"
#define endl '\n'

#define sq(x)           (x*x)

#define vll             vector<ll>
#define rev(v)          reverse(v.begin(),v.end())
#define srt(v)          sort(v.begin(),v.end())
#define grtsrt(v)       sort(v.begin(),v.end(),greater<int>())
#define mnv(v)          *min_element(v.begin(),v.end())
#define mxv(v)          *max_element(v.begin(),v.end())
#define all(v)          v.begin(),v.end()

#define Fas ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)

ll M= 998244353;

//--------------------------------------------functions-------------------------------------------------//

ll power(ll a,ll b){ll result=1;while(b>0){if(b%2 == 1){result *= a;} a *= a;b /= 2;}return result;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
ll countSetBits(ll x){ll Count=0;while(x>0){if(x&1) Count++;x=x>>1;}return Count;}
bool isPerfectSquare(ll n){ll sr = sqrt(n);if (sr * sr == n)return true;else return false;}
ll mod(ll x){return ((x%M + M)%M);}
ll add(ll a, ll b){return mod(mod(a)+mod(b));}
ll mul(ll a, ll b){return mod(mod(a)*mod(b));}
ll powerM(ll a,ll b){ll res=1;while(b){if(b%2==1){res=mul(a,res);}a=mul(a,a);b/=2;}return res;}
//------------------------------------sieve of erantothenes-----------------------------------------------//
//ll MAXN=100001;
//vector<ll> fact(MAXN);
//void sieve_of_erantothenes()
//{
//    fact[1] = 1;
//    for (ll i = 2; i <= MAXN; i++)
//        fact[i] = i;
//    for (ll i = 4; i <= MAXN; i += 2)
//        fact[i] = 2;
//    for (ll i = 3; i * i <= MAXN; i++){
//        if (fact[i] == i){
//            for (ll j = i * i; j <= MAXN; j += i)
//                if (fact[j] == j)
//                    fact[j] = i;
//        }
//    }
//}
//----------------------------------------nCr mod------------------------------------------------------//
ll modInverse(ll n){
    return powerM(n,M-2);
}
ll nCrM(ll n,ll r){
    if(n<r) return 0;
    if(r==0) return 1;
    vector<ll> fact(n+1);
    fact[0]=1;
    for(ll i=1;i<=n;i++){
        fact[i]=mul(fact[i-1],i);
    }
    return mul(mul(fact[n],modInverse(fact[r])),modInverse(fact[n-r]));
}
//-----------------------------------------------solve-----------------------------------------------------//
void solve() {
    ll n;cin>>n;
    vll v(n);
    trav(w, v) cin>>w;
    srt(v);
    ll ans;
    if(n>1){
        ll right=v[0];
        ans=mul(v[0],v[1]);
        for(ll i=1;i<n-1;i++){
            right=add(v[i],mul(2,right));
            ans=add(ans,mul(v[i+1],right));
        }
        for(ll i=0;i<n;i++){
            ans=add(ans,mul(v[i],v[i]));
        }
    }else{
        ans=mul(v[0],v[0]);
    }
    cout<<ans<<endl;
}

int main(){
    Fas;
//    ll t=0;
//    cin>>t;
//    while (t--)
        solve();

    return 0;
}
