#define _USE_MATH_DEFINES
#include <iostream>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <set>
#include <array>
#include <stdio.h>
#include <string.h>
#include <random>
#include <cassert>
using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using namespace std;
#define int long long
#define CONTAINS_VEC(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define ARY_REVERSE(v,a) (reverse((v), (v)+(a)))
#define REP(i, n) for (int (i)=0; (i) < (n); (i)++)
#define REPE(i, n) for (int (i)=0; (i) <= (n); (i)++)
#define CONTAINS_MAP(m, a) ((m).find((a)) != m.end())
#define CONTAINS_SET(m, a) ((m).find((a)) != m.end())
void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; exit(0); }
void Yes() { cout << "Yes" << endl; exit(0); }
void No() { cout << "No" << endl; exit(0); }




//---------- 1000000007 ----------
const int MOD = 998244353;
struct mint {
	ll x; // typedef long long ll;
	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;
	}

	// for prime mod
	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, mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }

mint m_comb(mint n, mint r)
{
	int i;
	mint p = 1;
	for (i = 1; i <= r.x; i++)
	{
		p *= n - i + 1;
		p /= i;
	}
	return p;
}
mint m_comb_with_rep(mint n, mint r)
{
	return m_comb(n + r - 1, r);
}
mint m_perm(mint n, mint r)
{
	mint a = 1;
	for (int i = n.x; i > n.x - r.x; i--)
	{
		a *= i;
	}
	return a;
}




int N;
int A[200001];

signed main()
{
	cin >> N;
	REP(i, N) cin >> A[i];

	ARY_SORT(A, N);

	mint ans = 0;
	mint sum = 0;
	mint b = 1;

	for (int i = 1; i < N; i++)
	{
		mint a = A[0] * A[i];
		sum += a * b;
		b *= 2;
	}

	ans = sum;

	for (int i = 0; i < N - 1; i++)
	{
		sum -= (A[i] * A[i + 1]);
		sum /= 2;
		sum /= A[i];
		sum *= A[i + 1];
		ans += sum;
	}

	for (int i = 0; i < N; i++)
	{
		mint a = A[i] * A[i];
		ans += a;
	}

	cout << ans << endl;
}



#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int N = 1e6 + 1, inf = 1e9, mod = 998244353;
ll modpow(ll x, ll p){
    ll ans = 1;
    for (ll i = p; i; i >>= 1, x = x * x % mod) if (i & 1) ans = ans * x % mod;
    return ans;
}
int main(){
    ios::sync_with_stdio(0), cin.tie(0);
    int n;
    cin >> n;
    ll a[n], pre[n], ans = 0;
    for (ll &i : a) cin >> i;
    sort(a, a + n);
    for (int i = 0; i < n; i++) pre[i] = ((i ? pre[i - 1] : 0) + a[i] * modpow(2, i)) % mod;
    for (int i = 0; i < n; i++){
        ll tmp = a[i] * (pre[n - 1] - pre[i]) % mod;
        tmp = tmp * modpow(modpow(2, i + 1), mod - 2) % mod;
        ans = (ans + tmp + a[i] * a[i]) % mod;
    }
    cout << ans;
}