#include<bits/stdc++.h>
using namespace std;
long long ans=0,num=0,a[200002];
int n;
int main(){
	scanf("%d",&n);
	for(int i=0;i<n;++i)scanf("%lld",&a[i]);
	sort(a,a+n);
	for(int i=n-2;i>=0;--i){
		num=(num+a[i+1])%998244353;
		ans=(ans+a[i]*num%998244353)%998244353;
		num=num*2%998244353;
	}
	for(int i=0;i<n;++i)ans=(ans+a[i]*a[i]%998244353)%998244353;
	printf("%lld",ans);
	return 0;
}
#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define ld long double

#define f first
#define s second
#define pb push_back

#define all(x) x.begin(), x.end()
#define mp(x, y) make_pair(x, y)
#define sz(li) (int) (li).size()
#define sum(a) (accumulate ((a).begin(), (a).end(), 0ll))
#define mine(a) (*min_element((a).begin(), (a).end()))
#define maxe(a) (*max_element((a).begin(), (a).end()))
#define mini(a) (min_element((a).begin(), (a).end()) - (a).begin())
#define maxi(a) (max_element((a).begin(), (a).end()) - (a).begin())
#define lowb(a, x) (lower_bound((a).begin(), (a).end(), (x)) - (a).begin())
#define uppb(a, x) (upper_bound((a).begin(), (a).end(), (x)) - (a).begin())

#define vi vector<int>
#define vl vector<ll>
#define vvi vector<vi>
#define vvl vector<vl>
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vpii vector<pii>
#define vpll vector<pll>

#define endl "\n"

template<typename A> ostream& operator<<(ostream &cout, vector<A> const &v);
template<typename A, typename B> ostream& operator<<(ostream &cout, pair<A, B> const &p) { return cout << "(" << p.f << ", " << p.s << ")"; }
template<typename A> ostream& operator<<(ostream &cout, vector<A> const &v) { cout << "[ "; for(int i = 0; i < v.size(); i++) {if (i) cout << ", "; cout << v[i];} return cout << " ]"; }
template<typename A> ostream& operator<<(ostream &cout, vector<vector<A>> const &v) { cout << "["; for (int i = 0; i < v.size(); i++) { if (i) { cout << " "; } cout << v[i]; if (i < v.size() - 1) { cout << endl; } } return cout << "]"; }
template<typename A, typename B> istream& operator>>(istream& cin, pair<A, B> &p) { cin >> p.first; return cin >> p.second; }
template<typename T, typename U> void cmin(T& a, U b){ if (a > b) a = b; }
template<typename T, typename U> void cmax(T& a, U b){ if (a < b) a = b; }

void solve() {
  int n; cin >> n;
  vi a(n);
  map<int, ll> freq;

  for (int i = 0; i < n; i++) {
    cin >> a[i];
    freq[a[i] % 200]++;
  }

  ll ans = 0;

  for (int i = 0; i < 200; i++) {
    ans += freq[i] * (freq[i] - 1) / 2;
  }


  cout << ans << endl;
}

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

  int t = 1;
  // cin >> t;

  while (t--) {
    solve();
  }

  cerr << "Time: " << 1000.0*clock()/CLOCKS_PER_SEC << " ms\n";
}