#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define ll long long
using namespace std;

int main(){
    ll n;cin>>n;
    vector<ll> vec(n), vecmax, vecall, vecminus;
    ll kaka=0, ka=0, choudoii=0;
    for(int i=0;i<n;i++){cin>>vec.at(i);kaka=max(vec.at(i), kaka);vecmax.push_back(kaka);ka+=vec.at(i);vecall.push_back(ka);choudoii-=vec.at(i)*(i+1);vecminus.push_back(choudoii);}
    for(int i=0;i<n;i++){
        ll ans=(i+2)*vecall.at(i)+(i+1)*vecmax.at(i)+vecminus.at(i);
        cout<<ans<<endl;
    }
}
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
	int n;
	long long l, res = 0, cval = 0, mod = 998244353;
	vector<long long> v;
	cin >> n;
	for(int i = 0; i < n; ++i) {
		cin >> l;
		v.push_back(l);
	}

	sort(v.begin(), v.end());

	for(auto l = v.begin(); l != v.end(); ++l) {
		res = (res + (cval + *l) * *l) % mod;
		cval = (2*cval + *l) % mod;
	}

	cout << res << endl;
	return 0;
}
