#include<set>
#include<map>
#include<queue>
#include<stack>
#include<cmath>
#include<ctime>
#include<bitset>
#include<vector>
#include<cstdio>
#include<complex>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>

using namespace std;
#define SZ(v) ((int)(v).size())  
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
typedef pair<int,int> PII;

template<class T>
inline void relax(T& a,const T& b) { a=((a>b) ? a : b); }
template<class T>
inline void tense(T& a,const T& b) { a=((a<b) ? a : b); }

template<class T>
inline void read(T& x)
{
	x=0;
	register bool sign=false;
	register char c;
	for(c=getchar();c<'0' || c>'9';c=getchar()) 
		if(c=='-') sign=true;
	for(;c>='0' && c<='9';c=getchar()) 
		x=(x<<1)+(x<<3)+(c&15);
	if(sign) x=~x+1;
} 

const int N=4e5+5;
const LL P=998244353;

int n;
LL a[N];

LL power(LL x,LL k,LL MOD)
{
	LL res=1; x%=MOD;
	while(k) {
		if(k&1) res=res*x%MOD;
		x=x*x%MOD; k>>=1;
	}
	return res%MOD;
}

int main()
{
//	freopen("1.in","r",stdin);
	int i;
	
	read(n);
	for(i=1;i<=n;i++) read(a[i]);
	sort(a+1,a+n+1);
	
	LL val=0;
	for(i=1;i<=n;i++) 
		val=(val+a[i]*power(2,i-1,P))%P;
	
	LL ans=0;
	for(i=1;i<=n;i++) {
		val=(val-a[i]+P)*power(2,P-2,P)%P;
		ans=(ans+val*a[i])%P;
		ans=(ans+a[i]*a[i])%P;
	}
	printf("%lld\n",ans);
	return 0;
}

#include <bits/stdc++.h>
#define fo(i, k, n) for (ll i = k; i < n; i++)
#define rfo(i, k, n) for (ll i = k; i >= n  ; i--)
#define ll long long
#define ld long double
#define que queue
#define pb push_back
#define mp make_pair
#define vi vector<int> 
#define vl vector<ll>
#define gcd(m,n) __gcd( m,  n)
#define sq(x)   (x*x)
#define rev(v)  reverse(v.begin(),v.end())
#define srt(v)  sort(v.begin(),v.end())
#define grtsrt(v) sort(v.begin(),v.end(),greater<int>())
#define mnv(v)     *min_element(v.begin(),v.end())
#define mxv(v)    *max_element(v.begin(),v.end())
#define all(v)    v.begin(),v.end()
#define toInteger(s) stoll(s) 
#define toString(num) to_string(num)

 

 
using namespace std;
ll MOD = 1e9 + 7;
//--------------------------------------------functions-------------------------------------------------//
 
ll power(ll a,ll b){ll result=1;while(b>0){if(b%2 == 1){result *= a;} a *= a;b /= 2;}return result;}
ll countSetBits(ll x){ll Count=0;while(x>0){if(x&1) Count++;x=x>>1;}return Count;}
bool isPerfectSquare(ll n){ll sr = sqrt(n);if (sr * sr == n)return true;else return false;}
ll mod(ll x,ll M){return ((x%M + M)%M);}
ll mul(ll a, ll b,ll M){return mod(mod(a,M)*mod(b,M),M);}
ll powerM(ll a,ll b,ll M){
    ll res=1ll;
    while(b){
        if(b%2ll==1ll){
            res=mul(a,res,M);
        }
        a=mul(a,a,M);b/=2ll;
    }
    return res;
}
int log22(long long x)
{
    return 64 - __builtin_clzll(x) - 1;
}

//--------------------------------------------SieveOfEratosthenes-------------------------------------------------//
//mem will have true if its prime.
void SieveOfEratosthenes( vector<bool>&mem)
{ ll n = 1e6 +1;
    
    bool prime[n + 1];
    memset(prime, true, sizeof(prime));
 
    for (int p = 2; p * p <= n; p++)
    {
        
        if (prime[p] == true)
        {
            for (int i = p * p; i <= n; i += p)
                prime[i] = false;
        }
    }
 
     fo(i,2,n)
     if(prime[i])mem[i]=true;
    
}


//--------------------------------------------solve-------------------------------------------------//



int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
 // freopen("input.txt","r",stdin); 
//freopen("output.txt","w",stdout);

  
     
  int n;
  cin>>n;

  vector<int>v(n);
  fo(i,0,n)
  cin>>v[i];
 ll ans = 0;
  fo(i,0,n)
  {
    if(v[i]>10)
        ans += v[i]-10;
  }
 cout<<ans;




 
 
 
 
 
  return 0;
}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

 
