#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#include <ext/pb_ds/detail/standard_policies.hpp>

using namespace std;
using namespace __gnu_pbds;

#pragma GCC optimize("Ofast")
#pragma GCC optimize("O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.1,sse4.2,tune=native")
 
#define mp make_pair
#define sz(x) (int)((x).size())
#define all(x) (x).begin(),(x).end()
#define FO(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}
#define eb emplace_back
 
typedef pair< int, int > pii;
typedef pair< long long, long long > pll;
typedef long long ll;
typedef unsigned long long ull;
typedef vector< int > vi;
typedef vector< vi > vvi;
typedef vector< ll > vll;
typedef vector< vll > vvll;
typedef vector< pii > vpii;
typedef vector< vpii > vvpii;
typedef vector< pll > vpll;
typedef long double ld;
typedef vector< ld > vld;
typedef unsigned int uint;

template <uint MD> struct ModInt {
    using M = ModInt;
    const static M G;
    uint v;
    ModInt(ll _v = 0) { set_v(uint(_v % MD + MD)); }
    M& set_v(uint _v) {
        v = (_v < MD) ? _v : _v - MD;
        return *this;
    }
    explicit operator bool() const { return v != 0; }
    M operator-() const { return M() - *this; }
    M operator+(const M& r) const { return M().set_v(v + r.v); }
    M operator-(const M& r) const { return M().set_v(v + MD - r.v); }
    M operator*(const M& r) const { return M().set_v(uint(ull(v) * r.v % MD)); }
    M operator/(const M& r) const { return *this * r.inv(); }
    M& operator+=(const M& r) { return *this = *this + r; }
    M& operator-=(const M& r) { return *this = *this - r; }
    M& operator*=(const M& r) { return *this = *this * r; }
    M& operator/=(const M& r) { return *this = *this / r; }
    bool operator==(const M& r) const { return v == r.v; }
    const bool operator<(const M& o) const {return v < o.v; }
    M pow(ll n) const {
        M x = *this, r = 1;
        while (n) {
            if (n & 1) r *= x;
            x *= x;
            n >>= 1;
        }
        return r;
    }
    M inv() const { return pow(MD - 2); }
    friend ostream& operator<<(ostream& os, const M& r) { return os << r.v; }
};    

using Mint = ModInt<998244353>;

int main() { 
    #ifdef BLAT
        freopen("stdin", "r", stdin);
        freopen("stderr", "w", stderr);
    #endif

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int n;
    cin >> n;

    vi v(n);

    for(auto &x : v) cin >> x;

    Mint ans = 0;
    vector< Mint > sp(n + 1);

    sort(all(v));
    for(int i = n-1; ~i; --i) {
        sp[i] = sp[i+1] + sp[i+1] + v[i];
        ans += sp[i+1] * v[i];
        ans += Mint(v[i]) * v[i];
    }

    cout << ans << '\n';

    #ifdef BLAT
        cerr << "\n\nConsumed " << clock() / (double)CLOCKS_PER_SEC << '\n';
    #endif
    return 0; 
}

#include<bits/stdc++.h>
typedef long long int ll;
using namespace std;
#define sz 200009
#define mod 998244353
#define inf 1e9
#define f first
#define s second
#define pa pair<ll,ll>
ll arr[sz],brr[sz];
long long binpow(long long a, long long b) {
    a %= mod;
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % mod;
        a = a * a % mod;
        b >>= 1;
    }
    return res;
}
int main()
{
 /// ios_base::sync_with_stdio(0);cin.tie(0);
 int test_case=1;
 //scanf("%d",&test_case);
 
 for(int cs=1;cs<=test_case;cs++)
 {
   ll n;
   scanf("%lld",&n);
   for(int i=1;i<=n;i++)
   {
    scanf("%lld",&arr[i]);
   }
   brr[0]=1;
   for(int i=1;i<=n;i++)
    brr[i]=(brr[i-1]*2)%mod;
  ll ans=0,sum=0;
  sort(arr+1,arr+n+1);
  for(int i=1;i<=n;i++)
  {
    ans=(ans+(arr[i]*arr[i])%mod)%mod;
    if(i>1)
      sum=(sum+(brr[i-2]*arr[i])%mod)%mod;
  }
 // printf("%lld\n",sum);
  ll a1=binpow(2,mod-2);
  for(int i=1;i<n;i++)
  {
    ans=(ans+(sum*arr[i])%mod)%mod;
    sum=(sum-arr[i+1]+mod)%mod;
    sum=(sum*a1)%mod;
  }
  printf("%lld\n",ans);
 }
  return 0;
  }
