#include<iostream>
using namespace std;
typedef long long ll;
const ll N = 2e5+10;
ll a[N],b[N],maxn[N],c[N];
ll n;
int main(){
    cin>>n;
    for(ll i=1;i<=n;i++){
        cin>>a[i];
    }
    maxn[1]=a[1];
    for(ll i=2;i<=n;i++){
        if(a[i]>maxn[i-1]){
            maxn[i]=a[i];
        }
        else{
            maxn[i]=maxn[i-1];
        }
    }
    b[1]=a[1];
    for(ll i=2;i<=n;i++){
        b[i]=b[i-1]+a[i];
    }
    c[1]=b[1];
    for(ll i=2;i<=n;i++){
        c[i]=c[i-1]+b[i];
    }

    for(ll i=1;i<=n;i++){
        ll ans = b[i]+c[i-1]+i*maxn[i];
        cout<<ans<<endl;
    }
}
#include <bits/stdc++.h>
#define all(a) (a).begin(), (a).end()
using namespace std;
using ll  = long long int;
using pii = pair<ll, ll>;
using vi = vector<ll>;
template <typename T> void out(const T& t) {cout << t << '\n';}
vi vin(int n) {vi res(n); for(auto&i:res)cin>>i; return res;}
ll in() {ll x; cin>>x; return x;}

const ll MOD = 998244353;
const int N = 2e5 + 5;
ll two[N];
ll twoinv = 499122177;
ll mmod(ll x, ll y) {
    if (x >= 0LL)
        return x % y;
    else
        return (y - (-x) % y) % y;
}
void solve() {
    two[0] = 1;
    for (int i = 1; i < N; ++i) two[i] = 2 * two[i-1] % MOD;
    ll n = in();
    vi a = vin(n);
    sort(all(a));
    ll f = 0;
    for (int i = n - 2; i >= 0; --i) f =(f+ a[i] * two[n - 2 - i]) % MOD;
    ll ans = (f+a[n-1]) * a[n-1]%MOD;
    for (int i = n - 2; i >= 0; --i) {
        f = mmod(f-a[i], MOD);
        f=f*twoinv%MOD;
        ans =(ans + a[i] * f) % MOD;
        ans =(ans + a[i]*a[i])%MOD;
        ans = ans % MOD;
    }
    out(ans);
}


int main() {
    ios::sync_with_stdio(false);cin.tie(0);
    int t=1;;while(t--)solve();return 0;
}
