#include <bits/stdc++.h>

using namespace std;

#define REP(i,n) for(int i=0;i<int(n);i++)
#define foreach(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
typedef long long ll;
typedef pair<int,int> P;

const ll MOD=998244353;
ll modpow(ll x,ll n){
    ll res=1;
    while(n!=0){
	if(n%2!=0) res=(res*x)%MOD;
	x=(x*x)%MOD;
	n/=2;
   }
    return res;
}

int main(void){
	ll i;

	cin.tie(0);  ios_base::sync_with_stdio(false);

	ll N;
	cin >> N;
	vector<ll> a(N+1);
	a[0]=-1;
	for(i=1;i<=N;i++) cin >> a[i];
	sort(a.begin(),a.end());

	ll S=(a[N]*a[N])%MOD;
	ll ans=S;
	for(i=N-1;i>=1;i--){
		if(a[i]!=0){
			ll x=(2*a[i]*S)%MOD;
			ll y=modpow(a[i+1],MOD-2);
			S=(x*y)%MOD;
			S+=(a[i]*a[i])%MOD;
			S-=(a[i]*a[i+1])%MOD;
			S=(S+MOD)%MOD;
			ans+=S;
			ans=ans%MOD;

		}else{
			break;
		}

	}

	cout << ans << endl;


	return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define vec vector<int>
#define vecp vector<pair<int,int>>
#define ll long long
#define ull unsigned long long
#define pb push_back
#define fr first
#define sc second
#define fr1(i,a,b) for(int i=a;i<b;i++)
#define fr2(i,a,b) for(int i=a;i>=b;i--)
#define fr3(i,a,b) for(int i=a;i<=b;i++)
#define umap unordered_map<int,int,custom_hash>
#define omap map<int,int>
#define uset unordered_set<int,custom_hash>
#define oset set<int>
#define pr pair<int,int>
#define mod 1000000007
#define mp make_pair
#define all(v) v.begin(),v.end()
#define ppb pop_back

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
void read(vec &v)
{
  for(auto &i:v)cin>>i;
}
bool power(int val)
{
  if(val%6==0||val%10==0||val%15==0)
    return true;
  return false;
}
void solve()
{
  int n;
  cin>>n;
  if(n==3)
  {
    cout<<"6 10 15"<<"\n";
    return ;
  }
  int i=6;
  fr1(j,0,n)
  {
    if(power(i))
      cout<<i<<" ";
    else
      j--;
    i++;
  }
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1;
    //cin>>t;
    fr3(i,1,t){
      // cout<<"Case #"<<i<<": ";
        solve();
    }
   return 0;
}