#include<iostream>
#include<algorithm>
#include<cstdlib>
#include<sstream>
#include<cstring>
#include<cstdio>
#include<string>
#include<deque>
#include<cmath>
#include<queue>
#include<set>
#include<map>

using namespace std;

const long long MOD = 998244353;

int n;
long long a[200010];

long long base[200010];

void init() {
	base[0] = 1;
	for (int i = 1 ; i < 200010 ; i++) {
		base[i] = (base[i - 1] * 2) % MOD;
	}
}


int main(void)
{
	init();
	
	scanf("%d", &n);
	for (int i = 0 ; i < n ; i++)
		scanf("%lld", &(a[i]));
		
	if (n == 1) {
		long long ans = (a[0] * a[0]) % MOD;
		printf("%lld\n", ans);
		return 0;
	}
	
	sort(a, a + n);
	
	long long sum = 0;
	long long item = 0;
	item = a[n - 1];
	sum = (sum + a[n - 1] * item) % MOD;
	item = a[n - 1] + a[n - 2];
	sum = (sum + a[n - 2] * item) % MOD;
	
	//item4 = a[n-4] + a[n-3] + 2*a[n-2] + 4*a[n-1]
	//item3 =          a[n-3] +   a[n-2] + 2*a[n-1]
	//item2 =                     a[n-2] +   a[n-1]
	for (int i = n - 3 ; i >= 0 ; i--) {
		item = item - a[i + 1];
		if (item < 0) item = item + MOD;
		
		item = (item * 2) % MOD;
		item = (item + a[i + 1] + a[i]) % MOD;
		
		long long curN = (a[i] * item) % MOD;
		sum = (sum + curN) % MOD;
	}
	
	printf("%lld\n", sum);
		
	return 0;
}

#include<bits/stdc++.h>
#define int long long
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
s.find_by_order(x) xth element in set
x.order_of_key(x) number of elements <x*/
#define ll long long
#define vi vector<int>
#define si set<int>
#define mii map<int,int>
#define pb push_back
#define pf push_front
#define PI acos(-1)
#define pii pair<int,int>
#define extract_word(s)  stringstream str(s); while(str>>word)
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define SET(s) cout<<fixed<<setprecision(s)
#define set0(a) memset(a,0,sizeof(a))
#define endl "\n"
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define lower_string(s) transform(all(s),s.begin(),::tolower)
#define upper_string(s) transform(all(s),s.begin(),::toupper)
#define len(s) (int)s.size()
#define F first
#define S second
template<typename T,typename U>
bool compare(T x,U y){return(abs(x-y)<=1e-9);}
const int MOD=998244353;
void solve()
{
int n;
cin>>n;
int a[n];
for(auto &x:a)
cin>>x;
sort(a,a+n);
ll ans=0;
for(auto &x:a)
ans=(ans+(x*x)%MOD)%MOD;
ll p=a[0];
for(int i=1;i<n;i++)
{
	ans=(ans+(a[i]*p)%MOD)%MOD;
	p=(p*2+a[i])%MOD;
}
cout<<ans;
}
signed main()
{
//code
fastio
int t=1;
//cin>>t;
while(t--)
{
solve();
cout<<endl;
}
}
