#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <bits/stdc++.h>

using namespace __gnu_pbds;
using namespace std;

using ll = long long;
using ld = long double;

typedef tree<
        int,
        null_type,
        less<int>,
        rb_tree_tag,
        tree_order_statistics_node_update>
        ordered_set;

#define mp make_pair


const int MOD =  998244353;

int mul(int a, int b) {
    return (1LL * a * b) % MOD;
}

int add(int a, int b) {
    int s = (a+b);
    if (s>=MOD) s-=MOD;
    return s;
}

int sub(int a, int b) {
    int s = (a+MOD-b);
    if (s>=MOD) s-=MOD;
    return s;
}

int po(int a, ll deg)
{
    if (deg==0) return 1;
    if (deg%2==1) return mul(a, po(a, deg-1));
    int t = po(a, deg/2);
    return mul(t, t);
}

int inv(int n)
{
    return po(n, MOD-2);
}


mt19937 rnd(time(0));

/*
const int LIM = 1e5 + 5;

vector<int> facs(LIM), invfacs(LIM);

void init()
{
    facs[0] = 1;
    for (int i = 1; i<LIM; i++) facs[i] = mul(facs[i-1], i);
    invfacs[LIM-1] = inv(facs[LIM-1]);
    for (int i = LIM-2; i>=0; i--) invfacs[i] = mul(invfacs[i+1], i+1);
}

int C(int n, int k)
{
    if (n<k) return 0;
    if (n<0 || k<0) return 0;
    return mul(facs[n], mul(invfacs[k], invfacs[n-k]));
}
*/

/*struct DSU
{
    vector<int> sz;
    vector<int> parent;
    void make_set(int v) {
        parent[v] = v;
        sz[v] = 1;
    }

    int find_set(int v) {
        if (v == parent[v])
            return v;
        return find_set(parent[v]);
    }

    void union_sets(int a, int b) {
        find_set(a);
        find_set(b);

        a = find_set(a);
        b = find_set(b);

        if (a != b) {
            if (sz[a] < sz[b])
                swap(a, b);
            parent[b] = a;
            sz[a] += sz[b];
        };
    }

    DSU (int n)
    {
        parent.resize(n);
        sz.resize(n);
        for (int i = 0; i<n; i++) make_set(i);
    }
};*/


int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(nullptr);

    int n; cin>>n;
    vector<int> a(n); for (int i = 0; i<n; i++) cin>>a[i];
    sort(a.begin(), a.end());

    //Need to count sum of a[i] * a[j] * 2^(j-i-1) = sum of a[j]*2^j * sum of (a[i]/2^i)

    int deg = 1; int invdeg = inv(2); int inv2 = inv(2);

    int ans = 0;

    int cur = 0;
    for (int i = 0; i<n; i++)
    {
        ans = add(ans, mul(cur, mul(a[i], deg)));
        cur = add(cur, mul(a[i], invdeg));
        deg = mul(deg, 2);
        invdeg = mul(invdeg, inv2);
        //cout<<cur<<' '<<ans<<endl;
    }
    for (int i = 0; i<n; i++) ans = add(ans, mul(a[i], a[i]));

    cout<<ans<<endl;

}

/*
2 3 4

Should give: 3*3 + 3*2 = 15 -> 19
 */
    #include <bits/stdc++.h>
    using namespace std;
    #include <math.h>
    #include <iomanip>
    #include <cstdint>
    #include <string>
    #include <sstream>
    template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
    template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
    #define rep(i,n) for (int i = 0; i < (n); ++i)
    typedef long long ll;
    using P=pair<ll,ll>;
    const int INF=1001001001;
    const int mod=998244353;
    
    struct mint {
      ll x; 
      mint(ll x=0):x((x%mod+mod)%mod){}
      mint operator-() const { return mint(-x);}
      mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
      }
      mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
      }
      mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
      mint operator+(const mint a) const { return mint(*this) += a;}
      mint operator-(const mint a) const { return mint(*this) -= a;}
      mint operator*(const mint a) const { return mint(*this) *= a;}
      mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
      }
       
      mint inv() const { return pow(mod-2);}
      mint& operator/=(const mint a) { return *this *= a.inv();}
      mint operator/(const mint a) const { return mint(*this) /= a;}
     };
      istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
      ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
      struct combination {
      vector<mint> fact, ifact;
      combination(int n):fact(n+1),ifact(n+1) {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
      }
      mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n]*ifact[k]*ifact[n-k];
      }
     } c(200005);

    void solve(){
      int n;
      cin>>n;
      vector<ll>a(n);
      rep(i,n){cin>>a[i];}
      sort(a.begin(),a.end());
      mint ans=0,s=a[n-1];
      for(int i=n-2;i>=0;i--){
        ans+=s*a[i];
        s*=2;
        s+=a[i];
      }
      rep(i,n){ans+=a[i]*a[i];}
      cout<<ans<<endl;
    }
    int main(){
      solve();
      return 0;
    }
