#include <bits/stdc++.h>

typedef long long ll;

const int P = 998244353;
const int N = 200000;
const int IV2 = (P + 1) >> 1;

inline int norm(int x) {if( x >= P ) x -= P; return x;}

int pw2[N + 5], ipw2[N + 5];

int a[N + 5], n;

int main() {
	scanf("%d", &n);
	for(int i=1;i<=n;i++) scanf("%d", &a[i]); std::sort(a + 1, a + n + 1);
	
	pw2[0] = ipw2[0] = 1;
	for(int i=1;i<=n;i++) {
		pw2[i] = norm(pw2[i - 1] << 1);
		ipw2[i] = (ll)ipw2[i - 1] * IV2 % P;
	}
	
	int ans = 0, t = 0;
	for(int i=n;i>=1;i--) {
		ans = (ans + (ll)a[i] * a[i]) % P;
		ans = (ans + (ll)t * a[i] % P * ipw2[i]) % P;
		t = (t + (ll)a[i] * pw2[i - 1]) % P;
	}
	printf("%d\n", ans);
}
#include <bits/stdc++.h>
using namespace std;
#define clr(a) memset(a, 0, sizeof(a))
#define full(a) memset(a, 0x3f, sizeof(a))
#define mset(a, b) memset(a, b, sizeof(a))
#define cpy(a,b) memcpy(a, b, sizeof(a))
#define fornext(x, i) for(signed i = hd[x], y = ver[i]; i; i = nxt[i], y = ver[i])
#define Rep(i, a, b) for(signed i = (signed)(a); i <= (signed)(b); ++i)
#define dRep(i, a, b) for(signed i = (signed)(a); i >= (signed)(b); --i)
#define IOset(a) freopen(a".in", "r", stdin), freopen(a".out", "w", stdout);
#define pb push_back
#define It iterator
#define endl '\n'
#define un unsigned
#define int ll
#define ll long long
#define db double
#define rept cerr<<1.0*clock()/CLOCKS_PER_SEC<<endl;
#define dbg cout<<"c "
#define dbug(x) cerr << #x " = " << (x) << endl
template<typename _T> inline void _prt(_T _d) { cerr << _d << ' '; }
template <typename _T, typename ...Args> inline void _prt(_T _d, Args ..._a) { _prt(_d), _prt(_a...); }
template <typename _T, typename ...Args> inline void prt(_T _d, Args ..._a) { _prt(_d), _prt(_a...), cerr<<endl; }
template <typename _T, typename ...Args> inline void prt(_T _d) { cerr << _d <<endl; }
template<typename _T> inline void rd(_T &_d) {
	signed _f; char _c; _f = 1,_d = 0; while (_c = getchar(), !isdigit(_c)) if(_c=='-') _f=-1;
	while (isdigit(_c)) _d = _d * 10 + _c - '0', _c = getchar();
	_d=_f*_d;
}
template <typename _T, typename ...Args> inline void rd(_T &_d, Args &..._a) { rd(_d); rd(_a...); }

const int N=2e5+5,M=998244353;
int n,a[N];

inline void ml(int &x,int v) {
	x=1LL*x*v%M;
}

inline int md(int x) {
	return x>=M?x-M:x;
}

inline void add(int &x,int v) {
	x+=v,x=x>=M?x-M:x,x=x<0?x+M:x;
}

signed main() {
	rd(n);
	Rep(i,1,n) rd(a[i]);
	sort(a+1,a+n+1);
	int ans=0,sum=0;
	Rep(i,1,n) {
		add(sum,a[i-1]);
		add(ans,a[i]*(sum+a[i])%M);
		sum=md(sum+sum);
	}
	cout<<ans<<endl;
	return 0;
}