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

int main() {
  int n;
  cin >> n;

  vector<long long> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a.at(i);
  }

  sort(a.begin(), a.end());

  long long m = 998244353;

  vector<long long> min_sum(n);
  min_sum.at(0) = a.at(0);
  if (n > 1) {
    for (int i = 1; i < n; i++) {
      min_sum.at(i) = (min_sum.at(i-1)*2-a.at(i-1)+a.at(i))%m;
    }
  }

  long long res = 0;
  for (int i = 0; i < n; i++) {
    res = (res+a.at(i)*min_sum.at(i)%m)%m;
  }

  cout << res << endl;
}
#include <bits/stdc++.h>

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

using namespace std;

// #define endl '\n'
#define int long long int
#define rep(i, a, b) for (int i = a; i < b; i++)
#define revrep(i, a, b) for (int i = a; i >= b; i--)
#define pb push_back
#define pii pair<int, int>
#define vi vector<int>
#define vii vector<pii>
#define min3(a, b, c) min(a, min(b, c))
#define max3(a, b, c) max(a, max(b, c))

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename T>
using ordered_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;


ostream &operator<<( ostream &output, const pii &p ) { output << p.first << " " << p.second;return output; }
istream &operator>>( istream &input, pii &p ) { input >> p.first >> p.second;return input; }
template<typename T>
void inline println(vector<T> args){ for(T i: args)cout<<i<<" ";cout<<endl; }
void amax(int& a, int b) { a = max(a, b); }
void amin(int& a, int b) { a = min(a, b); }
int ceilInt(int a, int b) {
    if(!b) return 0;
    if(a%b) return a/b + 1;
    return a/b;
}

int INF = 1e18;
int MOD = 998244353;

static int mod_inv(int a, int m = MOD) {
    int g = m, r = a, x = 0, y = 1;
    while (r != 0) {
        int q = g / r;
        g %= r; swap(g, r);
        x -= q * y; swap(x, y);
    }
    return x < 0 ? x + m : x;
}


void solve()
{
    int n; cin>>n;
    int arr[n];
    rep(i, 0, n) cin>>arr[i];
    vi two(n+1, 1), twoInv(n+1, 1);
    int inv = mod_inv(2);
    rep(i, 1, n+1) {
        twoInv[i] = (inv*twoInv[i-1])%MOD;
        two[i] = (2*two[i-1])%MOD;
    }
    auto f = [&](int i) {
        return (twoInv[i]*arr[i])%MOD;
    };
    sort(arr, arr+n);
    int ans = 0;
    int pre = 0;
    rep(i, 0, n) {
        if(i-1 >= 0)
            ans += (((pre*two[i-1])%MOD)*arr[i])%MOD;
        ans += (arr[i]*arr[i])%MOD;
        ans %= MOD;
        pre += f(i);
        pre %= MOD;
    }
    cout<<ans<<endl;
}

signed main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t = 1;
    // cin>>t;
    rep(i, 0, t)
    {   
        // cout<<"Case #"<<i+1<<": ";
        solve();
    }
    return 0;
}