#include<bits/stdc++.h>
using namespace std;
int main(){
   long long n,i,k,t,ans=0;
   cin>>n;
   unordered_map<long long,long long>  mp; 
   for(i=0; i<n; i++){
     cin>>k;
     t = k%200;
     mp[t]++;
   }
   for(auto x : mp){
      if(x.second>1){
         for(i=1; i<x.second; i++){
            ans = ans + i;
         }
      }
   }
 cout<<ans;
   return 0;
}

/*
**  Author: Kartikey Tewari
**  Time: 10-04-2021  13:06:53
*/

#include <bits/stdc++.h>
#define ll long long
#define mod (ll)998244353
using namespace std;

ll power (ll a, ll b)
{
    ll ans=1;
    while (b>=1)
    {
        if (b%2==1)
        {
            ans=(ans*a)%mod;
            b--;
        }
        else
        {
            a=(a*a)%mod;
            b=b/2;
        }
    }

    return ans;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    ll n;
    cin >> n;
    vector<ll> arr(n);
    for (ll i=0;i<=n-1;i++)
    {
        cin >> arr[i];
    }   

    sort(arr.begin(),arr.end());
    ll ans=0;
    ll pre=0;
    for (ll i=0;i<=n-1;i++)
    {
        ans=(ans+((pre*arr[i])%mod))%mod;
        pre=((pre*2)%mod+arr[i])%mod;
    }

    for (ll i=0;i<=n-1;i++)
    {
        ans=(ans+power(arr[i],2))%mod;
    }

    cout << ans << endl;
    return 0;
}