//g++ t.cpp -o t && t < p.txt
//d>p.txt&&t<p.txt&&t2<p.txt

#include <iostream> // 
#include <vector> //
#include <algorithm> // 
#include <queue> // 
#include <string> // 
#include <functional> // 
#include <set> // 
#include <unordered_map> // 
#include <random> // 
#include <ctime> // 
#include <bitset> // 
#include <cassert>

// #include <atcoder/all>
// using namespace atcoder;
// g++ t.cpp -o t -I .

#define DB cerr<<"D"<<endl

struct _zo{_zo(){std::cin.tie(nullptr);std::cout.tie(nullptr);std::ios::sync_with_stdio(false);}}__zo;
using namespace std; using ll=long long; using ld=long double; const int INF=1e9; const ll LINF=1e18; const double dINF = 1e18; const ld ldINF = 1e18; const double EPS = 1e-6;
using P=pair<ll,ll>;
using Q=pair<pair<ll,ll>,ll>;
const ll M = 998244353;
ll mod_pow(ll x, ll a) { ll an = 1; while(a > 0) { if (a&1) an = an * x % M; x = x * x % M; a >>= 1;} return an;}
ll mod_pow(ll x, ll a, ll m) { ll an = 1; while(a > 0) { if (a&1) an = an * x % m; x = x * x % m; a >>= 1;} return an;}
void add(ll& x, ll y) {x+=y; x%=M;}; void mul(ll& x, ll y) {x*=y; x%=M;}; template<typename T, typename U> void chmax(T& x, U y) {if (x<y) x=y;}; template<typename T, typename U> void chmin(T& x, U y) {if (x>y) x=y;} bool vaild(int x, int y, int hh, int ww){return 0<=x&&x<hh&&0<=y&&y<ww;}
ll gcd(ll a, ll b) {if (b==0) return a; else return gcd(b, a%b);}
int keta(ll a) {int res=0; while(a>0) res+=a%10, a/=10; return res;}
int ketasu(ll a) {int res=0; while(a>0) res++, a/=10; return res;}
const int up[]={1,-1,0,0}, lf[]={0,0,1,-1};

int main() {
  int n;cin>>n;
  ll a[n];
  for(int i=0;i<n;i++)cin>>a[i];
  sort(a,a+n);
  ll an=0, sm=0;
  for(int i=0;i<n;i++) {
    add(an, (sm + a[i]) * a[i] % M);
    sm = sm * 2 + a[i];
    sm %= M;
  }
  cout<<an<<endl;
}
// 

// ・配列の大きさok？　・priority_queueはgreater？　・debug消した？
// ・落ち着いて。提出まで4分待ってね……WJ……1/10……2/10……

// Thank you for making problems and running the contest

#include<iostream>
#include<bits/stdc++.h>
#include<math.h>
#include<vector>
#include<string>
#include<cstring>
#include<ctype.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional> // for less
using namespace __gnu_pbds;
using namespace std;

typedef tree<int, null_type, less<int>, rb_tree_tag,
			tree_order_statistics_node_update>
	new_data_set;
//   <<implemented_sorted_vector>>  new_data_set p;
//   <<insert_like_set>>           insert(key):log(n)
//<<accessing_iterator_by_index>> find_by_order(idx):log(n)
//	    <<accessing_by_value>>   order_of_key(key):log(n)
// << replace less<int> by greater<int> for descending order>>
// find(key), erase(find(key)) works the same!

#ifndef ONLINE_JUDGE // setting up print debugging
template<class K, class V>ostream& operator<<(ostream&s,const pair<K,V>&p){s<<'<'<<p.x<<", "<<p.y<<'>';return s;}
template<class T, class=typename T::value_type, class=typename enable_if<!is_same<T,string>::value>::type>
ostream& operator<<(ostream&s,const T&v){s<<'[';for(auto&x:v){s<<x<<", ";}if(!v.empty()){s<<"\b\b";}s<<']';return s;}
void __prnt(){cerr<<endl;} template<class T, class...Ts>void __prnt(T&&a,Ts&&...etc){cerr<<a<<' ';__prnt(etc...);}
#define print(...) __prnt(__VA_ARGS__)
#else
#define print(...)
#endif

typedef long long ll;
typedef long l;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define pb push_back
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ERR(x) cout<<#x<<"="<<x<<endl
#define ERR2(x,y) cout<<#x<<"="<<x<<" "<<#y<<"="<<y<<endl;
#define show(v) for(auto e: v) cout<<e<<" ";
#define showArr(A,n) for(int i=0;i<n;i++) cout<<A[i]<<" ";
#define PI 3.1415926535897932384626433832795
#define MOD 998244353
#define mp make_pair
#define ff first
#define ss second
#define umpit unordered_map<ll,ll>::iterator
#define mpit map<ll,ll>::iterator
#define setit set<ll>::iterator
#define all(v) v.begin(),v.end()

ll binexpy(ll x,ll n)
{
	if(n==0)
	{
		return 1;
	}
	else if(n%2==0)
	{
		return binexpy(x*x,n/2);
	}
	else
	{
		return x*binexpy(x*x,(n-1)/2);
	}

}
ll binexpymod(ll x,ll n,ll mod)
{
	ll prod = 1;
	if(n==0)
	{
		return 1;
	}
	else if(n%2==0)
	{
		prod = ((x%mod)*(x%mod))%mod;
		return binexpymod(prod,n/2,mod);
	}
	else{
		prod = ((x%mod)*(x%mod))%mod;
		return ((x%mod)*binexpymod(prod,(n-1)/2,mod))%mod;
	}
}

	//cout<<binexpy(2,60);
	//cout<<endl;
	//cout<<binexpymod(2,60,2);
ll modInverse(ll n, ll p)
{
	return binexpymod(n, p-2, p);
}

ll nCrmod(ll n, ll r, ll p)
{
if (r==0)
	return 1;
	ll fac[n+1];
	fac[0] = 1;
	for (ll i=1 ; i<=n; i++)
		fac[i] = fac[i-1]*i%p;

	return (fac[n]* modInverse(fac[r], p) % p *
			modInverse(fac[n-r], p) % p) % p;
}




int main()
{
	int t;
	t = 1;
	int Case = 0;
	while(t--)
	{
        ll n;
        cin >> n;
        vector<ll>A(n);
        ll ans = 0;
        for(int i=0;i<n;i++){
            cin >> A[i];
            ans = (  ans+(binexpymod(A[i], 2, MOD))  )%MOD;
        }
        sort(all(A));
        ll post = 0;
        for(int i=n-1;i>=1;i--){
            post = ((post*2)%MOD + A[i])%MOD;
            ll temp = (A[i-1]*post)%MOD;
            ans = (ans+temp)%MOD;
        }
        cout << ans << endl;
	}
	return 0;
}
