#include<cstdio>
using namespace std;
const int N = 2e5 + 10;
int d[N], n, h[200];
using LL = long long;
int main() {
    scanf("%d", &n);
    for(int i = 0; i < n; ++i) {
        scanf("%d", d + i);
        h[d[i] % 200] ++;
    }
    LL res = 0;
    for(int i = 0; i < 200; ++i) {
        res += (LL) h[i] * (h[i] - 1) / 2;
    }
    printf("%lld\n", res);
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
typedef long long int LL;
const int mod=998244353;
LL po(int p){
	if(p==0) return 1ll;
	LL ret=po(p/2);
	ret=ret*ret%mod;
	if(p&1) ret*=2;
	return ret%mod;
}
int main(){
	int n;
	scanf("%d",&n);
	LL a[n];
	for(int i=0;i<n;i++) scanf("%lld",a+i);
	sort(a,a+n);
	LL ans=0;
	for(int i=0;i<n;i++) ans=(ans+a[i]*a[i])%mod;
	LL sum=0,p=1;
	for(int i=1;i<n;i++){
		sum+=p*a[i];
		sum%=mod;
		p*=2;
		p%=mod;
	}
	for(int i=0;i<n-1;i++){
		ans=(ans+a[i]*sum)%mod;
		sum-=a[i+1];
		sum=(sum+mod)%mod;
		sum*=po(mod-2);
		sum%=mod;
	}
	cout<<ans<<"\n";
}