#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;

#include <iostream>
#include <cassert>

template<long long mod>
class modint{
private:
  using T = long long;
  T a;
public:
  constexpr modint(const long long x = 0) noexcept : a((x%mod+mod)%mod) {}
  constexpr T& value() noexcept { return a; }
  constexpr const T& value() const noexcept { return a; }
  constexpr modint operator-() const noexcept {
    return modint(0) -= *this;
  }
  constexpr modint operator+(const modint& rhs) const noexcept {
    return modint(*this) += rhs;
  }
  constexpr modint operator-(const modint& rhs) const noexcept {
    return modint(*this) -= rhs;
  }
  constexpr modint operator*(const modint& rhs) const noexcept {
    return modint(*this) *= rhs;
  }
  constexpr modint operator/(const modint& rhs) const noexcept {
    return modint(*this) /= rhs;
  }
  constexpr modint& operator+=(const modint& rhs) noexcept {
    a += rhs.a;
    if(a >= mod) a -= mod;
    return *this;
  }
  constexpr modint &operator-=(const modint& rhs) noexcept {
    if(a < rhs.a) a += mod;
    a -= rhs.a;
    return *this;
  }
  constexpr modint& operator*=(const modint& rhs) noexcept {
    a = a*rhs.a%mod;
    return *this;
  }
  constexpr modint& operator/=(const modint& rhs) noexcept {
    return *this *= rhs.inv();
  }
  constexpr bool operator==(const modint& rhs) const noexcept {
    return a == rhs.a;
  }
  constexpr bool operator!=(const modint& rhs) const noexcept {
    return not (*this == rhs);
  }
  constexpr modint pow(long long k) const noexcept {
    modint ret(1);
    modint x = k > 0 ? *this : this->inv();
    k = abs(k);
    while(k > 0){
      if(k&1) ret *= x;
      x *= x;
      k >>= 1;
    }
    return ret;
  }
  constexpr modint inv() const noexcept {
    return pow(mod-2);
  }
  friend std::ostream& operator<<(std::ostream &os, const modint &X) noexcept {
    return os << X.a;
  }
  friend std::istream& operator>>(std::istream &is, modint &X) noexcept {
    is >> X.a;
    X.a %= mod;
    if(X.a < 0) X.a += mod;
    return is;
  }
};

int main(){
  using mint = modint<998244353>;
  int n;

  cin >> n;
  vector<long long> A(n);
  for(int i = 0; i < n; ++i)
    cin >> A[i];
  sort(A.begin(),A.end());
  mint t = 0;
  for(int i = n-1; i >= 0; --i){
    t *= 2;
    t += A[i];
  }
  mint ans = 0;
  for(auto a : A){
    t -= a;
    t /= 2;
    ans += t*a + a*a;
  }
  cout << ans << endl;
}

#define IOS ios::sync_with_stdio(false);
#define rep(i, a, n) for(ll i=a;i<=n;i++)

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef long double lb;
#define put(x) cout<< x << "\n"
const int inf = 0x3f3f3f3f;
const int mod = 1e9 + 7;
const int N = 1e6 + 10;
ll n, m, t, k, l, r, ans, cnt, sum, flag;
double arr[N];

int main() {
    IOS;
    cin >> n;
    arr[n] = 0;
    for (int i = n - 1; i >= 0; i--) {
        arr[i] = arr[i + 1] + (1.0 * n / (n - i));
    }
    printf("%.6f\n", arr[0]-1);
    return 0;
}