#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using ll = long long;
using Graph = vector<vector<int>>;
const long long INF = 1LL << 60;
const int SINF = 1LL << 29;
const ll mod = 1000000000+7;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }



int main() {
    const int MOD = 998244353;
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];

    ll res = 0;
    rep(i, n) res += (a[i] * a[i]) % MOD;
    sort(all(a));
    ll sum = 0;
    for(int i=n-2; i>=0; i--) {
        sum = (2 * sum + a[i+1]) % MOD;
        res += (a[i] * sum) % MOD;
    }
    cout << res % MOD << endl;
}
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <vector>
#include <cstring>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <stack>
typedef long long ll;
typedef long double ld;
#define rep(i,n) for(ll i=0;i<n;i++)
using namespace std;
typedef vector<vector<int>> Graph;
template<typename T> inline bool chmax(T &a, T b) { return ((a < b) ? (a = b, true) : (false)); }
template<typename T> inline bool chmin(T &a, T b) { return ((a > b) ? (a = b, true) : (false)); }



//main area
int main(){
    ll N;
    cin >> N;
    vector<ll> A(N);
    rep(i,N) cin >> A[i];
    sort(A.begin(),A.end());
    ld ans = 0;
    rep(i,N) ans += A[i];
    ll median = A[N/2];
    rep(i,N) ans += abs(A[i] - median);
    cout << fixed << setprecision(10) << ans/(2.0*N) << endl;
}
/*



*/