#include <bits/stdc++.h>
using namespace std;

int mod = 998244353;
int add(int a, int b) { return a + b - (a + b >= mod) * mod; }
int sub(int a, int b) { return a - b + (a - b < 0) * mod; }
int mul(int a, int b) { return (1ll * a * b) % mod; }

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

    int n;
    cin >> n;
    int a[n], pre[n] = {}, ans = 0;

    for (int &x : a)
        cin >> x;
    sort(a, a + n);

    for (int i = 0; i < n; i++) {
        if (i > 1) {
            pre[i - 2] = mul(pre[i - 2], 2);
            pre[i - 1] = add(a[i - 1], pre[i - 2]);
        }
        pre[i] = add(i ? pre[i - 1] : 0, a[i]);
        ans = add(ans, mul(a[i], pre[i]));
    }
    cout << ans << '\n';
}
#include <algorithm>
#include <deque>
#include <iostream>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <set>
#include <utility>
#include <vector>

#define all(v) v.begin(), v.end()
#define rep(i, j) for (ll i = 0; i < j; ++i)
#define rep2(i, j, k) for (ll i = j; i <= k; ++i)
#define rep3(i, j, k) for (ll i = j; i >= k; --i)

using namespace std;

using ld = long double;
using ll = long long;
using pi = pair<int, int>;
using pl = pair<long, long>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;

constexpr int INF = 1000000000;
constexpr int MAX = 500000;
constexpr int MOD = 998244353;
constexpr ll INFLL = 1000000000000000000;

template <class S, class T> inline bool chmax(S &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

template <class S, class T> inline bool chmin(S &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

struct mint {
  ll x;

  mint(ll x = 0) : x((x % MOD + MOD) % MOD) {}
  mint operator+=(const mint &a) {
    x += a.x;
    if (x >= MOD)
      x -= MOD;
    return *this;
  }
  mint operator-=(const mint &a) {
    if (x < a.x)
      x += MOD;
    x -= a.x;
    return *this;
  }
  mint operator*=(const mint &a) {
    x = x * a.x % MOD;
    return *this;
  }
  mint operator/=(const mint &a) { return *this *= a.inv(); }
  mint operator+(const mint &a) const { return mint(*this) += a; }
  mint operator-(const mint &a) const { return mint(*this) -= a; }
  mint operator*(const mint &a) const { return mint(*this) *= a; }
  mint operator/(const mint &a) const { return mint(*this) /= a; }
  mint inv(void) const { return pow(MOD - 2); }
  mint pow(ll a) const {
    if (!a)
      return 1;
    mint t = pow(a >> 1);
    t *= t;
    if (a & 1)
      t *= (*this);
    return t;
  }
  friend ostream &operator<<(ostream &os, const mint &a) {
    os << a.x;
    return os;
  }
};

int main(void) {

  int n;
  cin >> n;

  vl a(n);
  rep(i, n) cin >> a[i];

  sort(all(a));

  mint sum = a[n - 1], ans = 0;
  rep3(i, n - 2, 0) {
    /* cout << sum << endl; */

    ans += sum * a[i];
    sum = sum * 2 + a[i];
  }

  rep(i, n) ans += a[i] * a[i];

  cout << ans << endl;

  return 0;
}
