#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <string>
#include <cmath>
#include <queue>
#include <tuple>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <random>
#include <set>
#include <stack>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <bits/stdc++.h>

#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i,i0,n) for(int (i)=(i0);(i)<(n);(i)++)
#define FORR(i,i0,n) for(int (i)=(n)-1; (i)>=(i0);(i)--)
#define SORT(x) sort(x.begin(),x.end())
#define SORTR(x) sort(x.begin(),x.end(),greater<int>())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple

using namespace std;
using ll = long long;
using LL = long long;
using comp = complex<double>;

typedef std::pair<int, int> pii;
typedef std::pair<int, double> pid;
typedef std::vector<int> vi;
typedef std::vector<pii> vii;

const double PI = 3.14159265358979323846264338327950L;
const int mod = 1e9+7;
const ll INF = 1LL<<60;


comp inC(){
    double x,y;
    cin >> x >> y;
    return {x,y};
}

struct container {
    int bottom, top, id;
    container(int id, int bottom, int top) : top(top), bottom(bottom), id(id) {
    }
};


struct Edge {
    ll to, from, cost;
    Edge(ll to, ll from, ll cost) :to(to), from(from), cost(cost) {}
    Edge(): to(-1), from(-1), cost(0){}
};

struct Data {
    ll cost,val;
    Data(ll cost=0, ll val=0) : cost(cost), val(val){}
    bool operator<(const Data& a) const {
        return cost > a.cost;
    }
};



struct edge{
    int a,b,c;
    edge(int a = -1,int b = -1, int c = -1):a(a),b(b),c(c){}
    bool operator<(const edge& a) const {
        return c > a.c;
    }
};



void solveA(){
    ll n;
    cin >> n;

    if (n==2){
        cout << "Same" << endl;
        return;
    }

    if (n%2==1){
        cout << "Odd" << endl;
        return;
    }

    if ((n/2)%2==1){
        cout << "Same" << endl;
    }
    else cout << "Even" << endl;


}

void solve(){
    int n;
    cin >> n;

    vector<ll> a(n);
    rep(i,n) cin >> a[i];

    int m = 998244353;


    ll cursum = 0;
    ll prevadd = 0;

    ll ans = 0;
    SORT(a);

    rep(i,n){
        ll add = a[i];

        cursum *= 2LL;
        cursum += prevadd;
        cursum %= m;

        ll mult = (cursum + add)%m;

        ll p = mult*add;
        p%=m;

        ans += p;
        ans %= m;

        prevadd = add;
    }


    cout << ans;



}


int main() {
    int T = 1;
    // cin >> T;

    while (T--) {
        solve();
        // cout << endl;
    }
}













#include <bits/stdc++.h>
using namespace std;
#define ll long long

ll mod1= 998244353;
ll pow_mod(ll a,ll b)
{
	ll res=1;
	while(b!=0)
	{
		if(b&1)
		{
			res=(res*a)%mod1;
		}
		a=(a*a)%mod1;
		b/=2;
	}
	return res;
}
 
ll inv_mod(ll x){
    return pow_mod(x,mod1-2);
}
int main()
{
  int t=1;
  //cin>>t;
  while(t-->0){
      int n;
      cin>>n;
      ll a[n];
      ll sum=0;
      ll dp[n];
      dp[0]=1;
      for(int i=1;i<n;i++){
          dp[i]=2*dp[i-1];
          dp[i]%=mod1;
      }
      for(int i=0;i<n;i++){
          cin>>a[i];
          sum=(sum+(a[i]*a[i])%mod1)%mod1;
          //sum%=mod1;
      }
      sort(a,a+n);
      
      ll prev[n+1];
      prev[n]=0;
      for(int i=n-1;i>=1;i--){
         prev[i]=(prev[i+1]+((a[i]*a[0])%mod1*(dp[i-1]%mod1))%mod1)%mod1;
         //prev[i]%=mod1;
      }
      sum=(sum+prev[1])%mod1;
    
      for(int i=2;i<=n-1;i++){
          
          prev[i]=(prev[i]*inv_mod(dp[i-1]))%mod1;
          prev[i]=(prev[i]*inv_mod(a[0]))%mod1;
          //prev[i]/=a[0];
          prev[i]*=a[i-1];
          prev[i]%=mod1;
          sum=(sum+prev[i])%mod1;
         
      }
      cout<<sum;
      
  }
  return 0;
}