#include <algorithm>
#include <iostream>
using namespace std;
typedef long long ll;

const ll MOD = 998244353;

int main()
{
    int n;
    cin >> n;
    ll s = 0;
    ll a[200005];
    for(int i = 0; i < n; i++) cin >> a[i];
    sort(a, a + n);
    ll ans = 0;
    for(int i = 0; i < n; i++){
        ans = (ans + a[i] * (s + a[i])) % MOD;
        s = (s * 2 + a[i]) % MOD;
    }
    cout << ans << endl;
}

#include<bits/stdc++.h>
#define L(i, j, k) for(int i = (j); i <= (k); i++) 
#define R(i, j, k) for(int i = (j); i >= (k); i--)
#define ll long long
#define sz(a) ((int) a.size())
#define vi vector<int>
using namespace std;
const int N = 5e5 + 7, inf = 1e9 + 7;
int n, a[N], b[N], cnt;
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	cin >> n;
	a[n] = 3 * 5 * 7 * 11;
	L(i, 1, 5000) if(i % 3 == 0 || i % 5 == 0 || i % 7 == 0 || i % 11 == 0) {
		a[++cnt] = i * 2;
		if(cnt == n - 1) break;
	}
	L(i, 1, n) cout << a[i] << " ";
	return 0;
}