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

typedef pair<int, int> pii;
typedef long long ll;

int N;
vector<int> arr;

struct BIT1 {
    vector<pii> tree;
    void init() {
        tree = vector<pii>(4*N, pii(-1, -1));
    }
    void upd(int idx, pii val, int l, int r, int n) {
        if(idx < l || r < idx) return;
        if(l == r) {
            tree[n] = val;
            return;
        }
        int m = (l + r)>>1;
        upd(idx, val, l, m, 2*n);
        upd(idx, val, m + 1, r, 2*n + 1);
        tree[n] = max(tree[2*n], tree[2*n + 1]);
    }
    pii quer(int a, int b, int l, int r, int n) {
        if(b < l || r < a) return pii(0, 0);
        if(a <= l && r <= b) return tree[n];
        int m = (l + r)>>1;
        pii L = quer(a, b, l, m, 2*n);
        pii R = quer(a, b, m + 1, r, 2*n + 1);
        return max(L, R);
    }
} bit1;

int Xn;
vector<int> X;
map<int, int> dx;

struct BIT2 {
    vector<ll> tree, lazy;
    void init() {
        tree = vector<ll>(4*Xn, 0);
        lazy = vector<ll>(4*Xn, -1);
    }
    void prop(int l, int r, int n) {
        if(lazy[n] != -1 && l != r) {
            int m = (l + r)>>1;
            tree[2*n] = lazy[n] * (m - l + 1);
            lazy[2*n] = lazy[n];
            tree[2*n + 1] = lazy[n] * (r - m);
            lazy[2*n] = lazy[n];
            lazy[n] = -1;
        }
    }
    void rupd(int a, int b, ll val, int l, int r, int n) {
        if(b < l || r < a) return;
        if(a <= l && r <= b) {
            tree[n] = val * (r - l + 1);
            lazy[n] = val;
            return;
        }
        prop(l, r, n);
        int m = (l + r)>>1;
        rupd(a, b, val, l, m, 2*n);
        rupd(a, b, val, m + 1, r, 2*n + 1);
        tree[n] = tree[2*n] + tree[2*n + 1];
    }
    void upd(int idx, ll val, int l, int r, int n) {
        if(idx < l || r < idx) return;
        if(l == r) {
            tree[n] += val;
            return;
        }
        prop(l, r, n);
        int m = (l + r)>>1;
        upd(idx, val, l, m, 2*n);
        upd(idx, val, m + 1, r, 2*n + 1);
        tree[n] = tree[2*n] + tree[2*n + 1];
    }
    ll quer(int a, int b, int l, int r, int n) {
        if(b < l || r < a) return 0;
        if(a <= l && r <= b) return tree[n];
        int m = (l + r)>>1;
        prop(l, r, n);
        ll L = quer(a, b, l, m, 2*n);
        ll R = quer(a, b, m + 1, r, 2*n + 1);
        return L + R;
    }
} sum, cnt;

vector<ll> S;

int main() {
    scanf("%d", &N);
    arr.resize(N);
    bit1.init();
    for(int i = 0; i < N; i++) {
        scanf("%d", &arr[i]);
        bit1.upd(i, pii(arr[i], -i), 0, N - 1, 1);
        X.push_back(arr[i]);
    }
    X.push_back(0);
    sort(X.begin(), X.end());
    X.resize(unique(X.begin(), X.end()) - X.begin());
    Xn = X.size();
    for(int i = 0; i < Xn; i++) dx[ X[i] ] = i;

    S = vector<ll>(N, 0);
    int R = N - 1;
    int pos = N - 1;
    sum.init();
    cnt.init();
    while(1) {
        if(R < 0) break;
        pii t = bit1.quer(0, R, 0, N - 1, 1);
        R = -t.second - 1;
        pii d = bit1.quer(0, R, 0, N - 1, 1);

        while(0 <= pos && -t.second <= pos) {
            sum.upd(dx[ arr[pos] ], arr[pos], 0, Xn - 1, 1);
            cnt.upd(dx[ arr[pos] ], 1, 0, Xn - 1, 1);
            pos--;
        }
        S[-t.second] += sum.quer(dx[d.first] + 1, Xn - 1, 0, Xn - 1, 1) - cnt.quer(dx[d.first] + 1, Xn - 1, 0, Xn - 1, 1) * d.first;
        int c = cnt.quer(dx[d.first] + 1, Xn - 1, 0, Xn - 1, 1);
        sum.upd(dx[d.first], (ll)d.first * c, 0, Xn - 1, 1);
        sum.rupd(dx[d.first] + 1, Xn - 1, 0, 0, Xn - 1, 1);
        cnt.upd(dx[d.first], c, 0, Xn - 1, 1);
        cnt.rupd(dx[d.first] + 1, Xn - 1, 0, 0, Xn - 1, 1);
    }
    for(int i = 0; i < N; i++) {
        printf("%lld\n", S[i]);
    }
}


Measured memory_bytes: 22904