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

const int64_t MOD = 1e9 + 7;
const int64_t MOD2 = 998244353;
const int INF = 2e9;
const long long inf = 1LL<<62;

template<int MOD> struct ModInt {
    static const int Mod = MOD; unsigned x; ModInt() : x(0) { }
    ModInt(signed sig) { x = sig < 0 ? sig % MOD + MOD : sig % MOD; }
    ModInt(signed long long sig) { x = sig < 0 ? sig % MOD + MOD : sig % MOD; }
    int get() const { return (int)x; }
    ModInt &operator+=(ModInt that) { if ((x += that.x) >= MOD) x -= MOD; return *this; }
    ModInt &operator-=(ModInt that) { if ((x += MOD - that.x) >= MOD) x -= MOD; return *this; }
    ModInt &operator*=(ModInt that) { x = (unsigned long long)x * that.x % MOD; return *this; }
    ModInt &operator/=(ModInt that) { return *this *= that.inverse(); }
    ModInt operator+(ModInt that) const { return ModInt(*this) += that; }
    ModInt operator-(ModInt that) const { return ModInt(*this) -= that; }
    ModInt operator*(ModInt that) const { return ModInt(*this) *= that; }
    ModInt operator/(ModInt that) const { return ModInt(*this) /= that; }
    ModInt inverse() const { long long a = x, b = MOD, u = 1, v = 0;
        while (b) { long long t = a / b; a -= t * b; std::swap(a, b); u -= t * v; std::swap(u, v); }
        return ModInt(u); }
    bool operator==(ModInt that) const { return x == that.x; }
    bool operator!=(ModInt that) const { return x != that.x; }
    ModInt operator-() const { ModInt t; t.x = x == 0 ? 0 : Mod - x; return t; }
};
template<int MOD> ostream& operator<<(ostream& st, const ModInt<MOD> a) { st << a.get(); return st; };
template<int MOD> ModInt<MOD> operator^(ModInt<MOD> a, unsigned long long k) {
    ModInt<MOD> r = 1; while (k) { if (k & 1) r *= a; a *= a; k >>= 1; } return r; }
typedef ModInt<998244353> mint;

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  mint ans = 0;
  for (int i=0; i<n; i++) {
    cin >> a[i];
    ans += mint(a[i])*mint(a[i]);
  }
  sort(a.begin(), a.end());
  vector<mint> acc(n+1, 0);
  for (int i=0; i<n; i++) {
    acc[i+1] = mint(2)*acc[i] + mint(a[i]);
  }
  for (int i=1; i<n; i++) {
    ans += mint(a[i])*acc[i];
  }
  cout << ans << endl;
}

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

#define int long long
typedef long long ll ;
typedef pair <int, int >  pii ;
typedef vector <int> vi ;
#define umap unordered_map
// #define endl '\n'

#define vec vector
#define all(v) (v).begin() , (v).end()
#define sumof(v) accumulate(all(v), 0LL, plus<ll>())
#define maxof(v) max_element(all(v))
#define minof(v) min_element(all(v))
#define rev(v) reverse(all(v))
#define sz(v)  (long long)(v).size()

#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define PI acos(-1)

#define tc(t) ll testcases ; cin >> testcases ; for(int testcase = 1 ; testcase <= testcases ; testcase++)
#define printstl(c) for (auto it = (c).begin(); it != --((c).end()); it++) cout << *it << " "; cout << *(c.rbegin()) << "\n" << flush
#define printv(v, s, e) for(int i=(s); i<(e); i++) cout<<(v)[i]<<" "; cout<<endl
#define printnl(v) cout << v << "\n" << flush
#define invec(vec_name, vec_size) vec<ll> vec_name(vec_size); for(int i=0; i<vec_size; i++) cin >> vec_name[i];
#define fastio ios::sync_with_stdio(false); cin.tie(0);

#ifndef ONLINE_JUDGE
#define pr(...) dbs(#__VA_ARGS__, __VA_ARGS__);
#else
#define pr(...) {} ;
#endif
#define Printer os << "[ "; for (auto &it : p) os << it << " "; return os << "]";
#define PairPrint return os << "(" << p.first << ", " << p.second << ")";
#define printCase(n) cout<<"Case #"<<(n)<<":"<<" "
template <class T> ostream &operator <<(ostream &os, const vector<T> &p) {Printer}
template <class T> ostream &operator <<(ostream &os, const unordered_set<T> &p) {Printer}
template <class T> ostream &operator <<(ostream &os, const set<T> &p){Printer}
template <class T> ostream &operator <<(ostream &os, const multiset<T> &p){Printer}
template <class S, class T> ostream &operator <<(ostream &os, const pair<S, T> &p) {PairPrint}
template <class S, class T> ostream &operator <<(ostream &os, const unordered_map<S, T> &p){Printer}
template <class S, class T> ostream &operator <<(ostream &os, const map<S, T> &p){Printer}
template <class T> void dbs(string str, T t) {cerr << str << " : " << t << "\n"; } 
template <class T, class... S> void dbs(string str, T t, S... s) {int idx = str.find(','); cerr << str.substr(0, idx) << " : " << t << ", "; dbs(str.substr(idx + 1), s...); }
ll modExp(ll x, ll y, ll mod) {x %= mod, y %= (mod - 1) ; ll res = 1; while (y) {if (y & 1) res = (res * x) % mod; y /= 2, x = (x * x) % mod; } return res % mod; }
int cel(int num, int den) {if(num % den == 0) return num / den; else return 1 + num / den; } 
// vi r = {0,1,1,0};
// vi c = {0,1,0,1};
// vector<int> getRand(int x, int val)
// {
//     srand(time(NULL));
//     vi random;
//     for(int i=0; i<x; i++) random.pb(rand()%val);
//     return random;
// }
vector<int> constructPrefix(vector<int> v, int mod)
{
    int n = v.size();
    vector<int> ans;
    int sum = 0;
    for(int i = 0; i < n; i++)
    {
        sum = (sum%mod + v[i]%mod)%mod;
        ans.push_back(sum);
    }
    return ans;
}
// void seive()
// {
//     for(int i = 2; i <= LIMIT; i++)
//     {
//         if(not done[i])
//         {
//             primes.pb(i);
//             for(int j = i; j <= LIMIT; j += i)
//             {
//                 done[j] = 1;
//             }
//         }
//     }
// }
// void getFreq(vi &v, map<int, int> &m)
// {
//     for(int i = 0; i < v.size(); i++)
//     {
//         m[v[i]]++;
//     }
// }



int32_t main()
{
    fastio
    #ifndef ONLINE_JUDGE
        freopen("./input.txt", "r", stdin);
    #endif
  
        int n;
        cin>>n;
        invec(v,n);
        sort(all(v));
        vi mn(n,0), dp(n,0);
        mn[0]= v[0];
        int mod = 998244353;
        dp[0]= (v[0]*v[0])%mod;
        for(int i=1; i<n; i++)
        {
            v[i] = v[i]%mod;
            mn[i] = (mn[i-1]*2 +v[i])%mod;
            dp[i]= (dp[i-1]%mod + (((mn[i-1] + v[i])%mod)*v[i])%mod)%mod;
        }
        // pr(dp)
        cout<<dp[n-1]<<endl;
    
}