#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define all(a) a.begin(), a.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;
typedef long long ll;

template<typename Monoid>
struct LazySegmentTree{ //遅延評価セグメント木 (1-indexed)
private:

    int sz = 1, hei = 0;
    vector<Monoid> node, lazy;
    using Func1 = function<Monoid(Monoid, Monoid)>; //同一の配列内の値どうしの演算
    using Func2 = function<Monoid(Monoid, Monoid, int)>; //遅延配列の値をマージする演算
    const Func1 pick_n, pick_l; const Func2 merge;
    const Monoid init_n, init_l;

    inline Monoid reflect(int i, int l){
        return lazy[i] == init_l ? node[i] : merge(node[i], lazy[i], l);
    }
    
    inline void propagate(int i, int l){ //遅延配列を伝搬させる
        if(lazy[i] == init_l)return;
        if(i < sz){
            lazy[i << 1] = pick_l(lazy[i << 1], lazy[i]);
            lazy[i << 1 | 1] = pick_l(lazy[i << 1 | 1], lazy[i]);
        }
        node[i] = merge(node[i], lazy[i], l);
        lazy[i] = init_l;
    }

public:

    LazySegmentTree(vector<Monoid> vec, Monoid m1, const Monoid m2, 
                    const Func1 f1, const Func1 f2, const Func2 f3)
                    : init_n(m1), init_l(m2), pick_n(f1), pick_l(f2), merge(f3) {
        while(sz < (int)vec.size())sz <<= 1, ++hei;
        node = vector<Monoid>(sz << 1, init_n);
        lazy = vector<Monoid>(sz << 1, init_l);
        for(int i = 0; i < (int)vec.size(); i++){
            node[i + sz] = vec[i];
        }
        for(int i = sz - 1; i >= 1; i--){
            node[i] = pick_n(node[i << 1], node[i << 1 | 1]);
        }
    }

    void update(int l, int r, Monoid v){ //区間の値に対する操作
        l += sz, r += sz - 1;
        for(int i = hei; i >= 0; i--){
            propagate(l >> i, 1 << i);
            propagate(r >> i, 1 << i);
        }
        for(int tl = l, tr = r + 1, i = 1; tl < tr; tl >>= 1, tr >>= 1, i <<= 1){
            if(tl & 1)lazy[tl] = pick_l(lazy[tl], v), propagate(tl++, i);
            if(tr & 1)lazy[--tr] = pick_l(lazy[tr], v), propagate(tr, i);
        }
        int i = 0;
        while(l >>= 1, r >>= 1, l > 0){
            node[l] = pick_n(reflect(l << 1, 1 << i), reflect(l << 1 | 1, 1 << i));
            node[r] = pick_n(reflect(r << 1, 1 << i), reflect(r << 1 | 1, 1 << i));
            i++;
        }
    }

    Monoid get(int l, int r){ //区間取得
        Monoid res = init_n;
        l += sz, r += sz - 1;
        for(int i = hei; i >= 0; i--){
            propagate(l >> i, 1 << i);
            propagate(r >> i, 1 << i);
        }
        int i = 1;
        for(++r; l < r; l >>= 1, r >>= 1, i <<= 1){
            if(l & 1)propagate(l, i), res = pick_n(res, node[l++]);
            if(r & 1)propagate(--r, i), res = pick_n(res, node[r]);
        }
        return res;
    }

    inline Monoid operator [] (int i){ //[]でアクセス
        return get(i, i + 1);
    }

};

int main(){

    int n;
    cin >> n;
    
    vector<int> a(n);
    rep(i, n)cin >> a[i];

    vector<int> ord;
    int now = 0;
    rep(i, n)if(chmax(now, a[i]))ord.push_back(i);
    reverse(all(ord));

    vector<ll> v(n);
    rep(i, n)v[i] = a[i];
    sort(all(v));
    auto f = [](ll x, ll y){ return x + y; };
    auto g = [](ll x, ll y){ return y; };
    auto h = [](ll x, ll y, int l){ return y * l; };
    LazySegmentTree<ll> seg(v, 0, -1, f, g, h);

    vector<ll> ans(n, 0);
    rep(loop, (int)ord.size()){
        if(loop == (int)ord.size() - 1){
            ans[ord[loop]] = seg.get(0, n);
            seg.update(0, n, 0);
        } else {
            ll next = a[ord[loop + 1]];
            int pos = lower_bound(all(v), next) - v.begin();
            ans[ord[loop]] = seg.get(pos, n) - next * (n - pos);
            seg.update(pos, n, next);
        }
    }

    for(ll x : ans){
        cout << x << endl;
    }

}

Measured memory_bytes: 7528