#include<cstdio>
#include <algorithm>
#include <string>
#include <string.h>
#include <math.h>
#include <map>
#include<vector>
#include <iostream>
using namespace std;
#define ll long long
#define mod 998244353
ll a[200005];
ll mul(ll a,ll n)
{
    ll sum=1;
    while(n)
    {
        if(n%2) sum=sum*a%mod;
        a=a*a%mod;
        n/=2;
    }
    return sum;
}
ll get(ll p)
{
    return mul(p,mod-2);
}
int main()
{

    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%lld",&a[i]);
    }
    sort(a+1,a+n+1);
    ll sum=0;
    ll ans=0;
    for(int i=n;i>=1;i--)
    {
        ans=(ans+a[i]*a[i]%mod+sum*a[i]%mod)%mod;
        sum=(sum*2+a[i])%mod;
    }
    printf("%lld\n",ans);
    return 0;
}
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <cstdio>
#include <limits>
#define rep(i,n) for(int i = 0; i < n; ++i)
#define rep1(i,n) for(int i = 1; i <= n; ++i)
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if(a < b){ a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if(a > b){ a = b; return 1; } return 0; }
template<class T> inline int  sz(T &a) { return a.size(); }
using ll = long long; using ld = long double;
using pi = pair<int,int>; using pl = pair<ll,ll>;
using vi = vector<int>; using vvi = vector<vi>;
using vl = vector<ll>; using vvl = vector<vl>;
const int inf = numeric_limits<int>::max();
const ll infll = numeric_limits<ll>::max();
// Modint
// modint<MOD> で宣言
template<long long MOD>
struct modint{
  long long x;
  long long mod = MOD;
  modint(long long x=0):x(x%MOD){}
  modint& operator+=(const modint a){
    if((x+=a.x)>=MOD) x-=MOD;
    return *this;
  }
  modint& operator-=(const modint a){
    if((x += MOD-a.x)>=MOD) x-=MOD;
    return *this;
  }
  modint& operator*=(const modint a){
    (x*=a.x)%=MOD;
    return *this;
  }
  modint operator+(const modint a) const{
    modint res(*this);
    return res+=a;
  }
  modint operator-(const modint a) const{
    modint res(*this);
    return res-=a;
  }
  modint operator*(const modint a) const{
    modint res(*this);
    return res*=a;
  }
  modint pow(long long t) const{
    if(!t) return 1;
    modint a = pow(t>>1);
    a*=a;
    if(t&1) a*=*this;
    return a;
  }
  
  //for prime mod
  modint inv() const{
    return pow(MOD-2);
  }
  modint& operator/=(const modint a){
    return (*this) *= a.inv();
  }
  modint operator/(const modint a) const{
    modint res(*this);
    return res/=a;
  }
};
using mint = modint<998244353>;

const int NMAX=1000010; // we can calculate nCk until n is equal to NMAX
mint fact[NMAX],infac[NMAX];
void Make_Fact(){
  fact[0]=fact[1]=1;
  for(int i=2;i<=NMAX-1;++i){
    fact[i]=fact[i-1]*(mint)i;
  }
}
void Make_InvFact(){
  infac[0]=infac[1]=1;
  for(int i=2;i<=NMAX-1;++i){
    infac[i]=infac[i-1]/(mint)i;	
  }
}
mint Comb(int n,int k){
  if(n<0||k<0||n-k<0) return 0;
  return fact[n]*infac[k]*infac[n-k];
}



int main()
{
  int n; cin >> n;
  vector<mint> pow2(n+1);
  pow2[0].x = 1;
  rep(i,n) pow2[i+1] = pow2[i] * mint(2);
  vi a(n);
  rep(i,n) cin >> a[i];

  sort(a.begin(),a.end());
  mint res;
  mint sum;
  rep1(i,n-1) {
    sum += mint(a[i]) * pow2[i-1];
  }
  rep(i,n) {
    res += mint(a[i]) * sum;
    res += mint(a[i]) * mint(a[i]);
    if(i+1 < n) {
      sum -= a[i+1];
      sum /= mint(2);
    }
  }
  cout << res.x << "\n";

  return 0;
}
