
//#include <atcoder/maxflow.hpp>
#include <memory>
#include <iostream>
#include <map>
#include <list>
#include <set>
#include <algorithm>
#include <vector>
#include <sstream>
#include <string>
#include <functional>
#include <queue>
#include <deque>
#include <stack>
#include <limits>
#include <unordered_map>
#include <unordered_set>
#include <cmath>
#include <fstream>
#include <iterator>
#include <random>
#include <chrono>
#include <complex>
#include <thread>

#define forr(i,start,count) for (int i = (start); i < (start)+(count); ++i)
#define set_map_includes(set, elt) (set.find((elt)) != set.end())
#define readint(i) int i; cin >> i
#define readll(i) ll i; cin >> i
#define readdouble(i) double i; cin >> i
#define readstring(s) string s; cin >> s

typedef long long ll;

using namespace std;
//using namespace atcoder;

ll modd = (1000LL * 1000LL * 1000LL + 7LL);
//ll modd = 998244353;

int main()   {

    ios_base::sync_with_stdio(false);

    cout.precision(17);
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    uniform_int_distribution<int> rand_gen(0, modd);   // rand_gen(rng) gets the rand no

    auto start = chrono::steady_clock::now();

//    readint(test_cases);
    int test_cases = 1;
    forr(t, 1, test_cases) {
        readint(n);
        vector<ll> a;
        forr(i,0,n) {
            readint(aa); a.push_back(aa);
        }
        sort(a.begin(), a.end());
        vector<ll> part_sum; part_sum.push_back(0);
        forr(i,0,n) {
            part_sum.push_back(a[i] + part_sum.back());
        }

        ll sum = 0;
        forr(i,0,n) {
            sum += i*a[i] - part_sum[i];
            sum += part_sum.back() - part_sum[i] - (n-i)*a[i];
        }
        cout << sum/2 << endl;
    }
//        auto stop = chrono::steady_clock::now(); 
//        auto duration = chrono::duration_cast<chrono::milliseconds>(stop - start);
//        cout << "Duration: " << duration.count() << endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int n, x, mx; ll s, t;
void solve() {
    cin >> n;
    for (int i = 1; i <= n; ++i) {
        cin >> x;
        s += x, t += s;
        mx = max(mx, x);
        cout << t + 1ll * i * mx << "\n";
    }
}
int main() {
    ios::sync_with_stdio(false), cin.tie(nullptr);
    solve();
    return 0;
}