#include <bits/stdc++.h>
	
using namespace std;
void solve(){
	int n;
	cin >> n;
	int a[n];
	int m=0,sum=0;
	for(int i=0;i<n;i++){
		cin >> a[i];
		m = a[i]-10;
		if(m>0)
		sum += m;
	}
	cout << sum;
}
int main()
{
	std::ios::sync_with_stdio(false);
	//int T;
	//cin >> T;
	// cin.ignore(); must be there when using getline(cin, s)
	//while(T--)
	//{
		solve();
	//}
	return 0;
}

/*Allah Vorosha*/
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define pb push_back
#define in insert
#define rev reverse
#define all(x) (x).begin(),(x).end()
#define all2(x) (x).rbegin(),(x).rend()
#define sz(v) (int)v.size()
#define yes cout << "YES\n"
#define no cout << "NO\n";
#define take for(auto &it : a) cin >> it;
#define vi vector<int>
#define vii vector<pair<int, int > >
#define vl vector<ll>
#define fi first
#define se second
#define l_b lower_bound
#define u_b upper_bound
#define ed printf("\n")
#define ios ios_base::sync_with_stdio(0);cin.tie();cout.tie();

using namespace std;

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<class T> void read(T &x) { cin >> x; }
template<class T, class ...U> void read(T &x, U& ... u) { read(x); read(u...); }
template<class T> void print1(const T &x) { cout << x << '\n'; }
template<class T, class ...U> void print1(const T &x, const U& ... u) { print1(x); print1(u...); }
template<class T> void print2(const T &x) { cout << x << ' '; }
template<class T, class ...U> void print2(const T &x, const U& ... u) { print2(x); print2(u...); }

const int N = 51, mod = 998244353, M = 5e5 + 5;
const ll inf = 9e18;
//int cs = 1;

int bp(int x) {
    return __builtin_popcount(x);
}

void solve() {
    int n;
    read(n);
    vi a(n);
    take;
    ll ans = 0, temp = 0;
    sort(all(a));
    for(int i = 0; i < n; i++) {
        ans += temp * a[i];
        ans %= mod;
        ans += a[i] * 1ll * a[i];
        ans %= mod;
        temp *= 2;
        //temp %= mod;
        temp += a[i];
        temp %= mod;
    }
    print1(ans);
}

int main() {
    ios;
    solve();
    return 0;
}
