#include <bits/stdc++.h>
#define INF 0x3f3f3f3f
#define rep(i, a, n) for (int i=(a); i<(n); i++)
#define per(i, a, n) for (int i=(a); i>(n); i--)
typedef long long ll;
const int maxn = 2e5+5;
const int mod = 998244353;
using namespace std;

ll fpow(ll base, ll exp) {
	ll res = 1;
	while(exp) {
		if ( exp&1 )
			res = (res*base) % mod;
		exp >>= 1;
		base = (base*base) % mod;
	}
	return res;
}

void solve() {
	int n; cin >> n;
	vector<ll> v(n),pre(n+1);
	ll ans = 0;
	rep(i,0,n) cin >> v[i], ans = (ans + v[i] * v[i] % mod) % mod;
	sort(v.begin(), v.end());
	//pre[0] = v[0];
	rep(i,1,n) pre[i] = v[i];
	pre[0] = v[0];
	rep(i,1,n) {
		pre[i] = (pre[i] + pre[i-1] * 2 % mod) % mod;
		ans = (ans + v[i]*pre[i-1]%mod)%mod;
	}
	cout << ans << '\n';
}

int main(int argc, char * argv[]) {
	ios_base::sync_with_stdio(false); cin.tie(0);
	//int t; cin >> t; while(t--)
	solve();

    return 0;
}
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>

using namespace std;

constexpr int MOD = 998244353;
struct M {
    int v;
    M(int x = 0) {
        if (x < -MOD || x >= MOD) x %= MOD;
        v = (x >= 0) ? x : x + MOD;
    }
    explicit operator int() const { return v; }
    bool operator==(const M& b) const { return v == b.v; }
    bool operator!=(const M& b) const { return v != b.v; }
    M operator-() { return M(-v); }
    M operator+=(const M& b) { if ((v += b.v) >= MOD) v -= MOD; return *this; }
    M operator-=(const M& b) { if ((v -= b.v) < 0) v += MOD; return *this; }
    M operator*=(const M& b) { v = (long long)v * b.v % MOD; return *this; }
    M operator/=(const M& b) { return *this *= b ^ (MOD - 2); }
    friend M operator^(M a, int b) {
        M ret = 1;
        for (; b; a *= a, b >>= 1) if (b & 1) ret *= a;
        return ret;
    }
    friend M operator+(M a, const M& b) { return a += b; }
    friend M operator-(M a, const M& b) { return a -= b; }
    friend M operator*(M a, const M& b) { return a *= b; }
    friend M operator/(M a, const M& b) { return a /= b; }
};
using Mod = M;

void solve() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int &i : a) {
        cin >> i;
    }

    sort(a.begin(), a.end());
    Mod ans = 0;
    for (int &i : a) {
        ans += Mod(i) * i;
    }

    Mod cur = 0;
    for (int i = 0; i < n; i++) {
        ans += cur * a[i];
        cur = cur * 2 + a[i];
    }
    cout << int(ans) << '\n';
}

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
    // int owo; cin >> owo;
    int owo = 1;
    while (owo--) solve();
}
