#include <bits/stdc++.h>

#define show(x) cout << #x << " = " << x << endl

using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;

template <typename T>
ostream& operator<<(ostream& os, const vector<T>& v)
{
    os << "sz=" << v.size() << "\n[";
    for (const auto& p : v) {
        os << p << ",";
    }
    os << "]\n";
    return os;
}

template <typename S, typename T>
ostream& operator<<(ostream& os, const pair<S, T>& p)
{
    os << "(" << p.first << "," << p.second
       << ")";
    return os;
}


constexpr ll MOD = 1e9 + 7;

template <typename T>
constexpr T INF = numeric_limits<T>::max() / 100;

template <typename Base>
struct SegmentTree {
public:
    using BaseAlgebra = Base;
    using AccMonoid = typename BaseAlgebra::AccMonoid;
    using OpMonoid = typename BaseAlgebra::OpMonoid;
    using T = typename BaseAlgebra::T;
    using F = typename BaseAlgebra::OpMonoid::T;

    SegmentTree(const ll n) : data_num(n), height(__lg(2 * data_num - 1)), size(1 << (1 + height)), half(size >> 1), value(size, AccMonoid::identity()), action(size, OpMonoid::identity()) { assert(n > 0); }
    SegmentTree(const std::vector<T>& val) : data_num(val.size()), height(__lg(2 * data_num - 1)), size(1 << (1 + height)), half(size >> 1), value(size), action(size, OpMonoid::identity())
    {
        for (ll data = 0; data < half; data++) {
            if (data < data_num) {
                value[data + half] = val[data];
            } else {
                value[data + half] = AccMonoid::identity();
            }
        }
        for (ll node = half - 1; node >= 1; node--) {
            value[node] = acc(value[2 * node], value[2 * node + 1]);
        }
    }

    T get(const ll a) const
    {
        assert(0 <= a and a < data_num);
        return accumulate(a, a + 1);
    }

    void set(const ll a, const T& val)
    {
        assert(0 <= a and a < data_num);
        const ll node = a + half;
        value[node] = val;
        for (ll i = node / 2; i > 0; i /= 2) {
            value[i] = acc(value[2 * i], value[2 * i + 1]);
        }
    }

    T accumulate(const ll a, const ll b) const  // Accumulate (a,b]
    {
        assert(0 <= a and a < b and b <= data_num);
        return accumulateRec(1, 0, half, a, b);
    }

    void modify(const ll a, const ll b, const F& f)  // Apply f on (a,b]
    {
        assert(0 <= a and a < b and b <= data_num);
        if (f == OpMonoid::identity()) {
            return;
        }
        modifyRec(1, 0, half, a, b, f);
    }

    void print() const
    {
        // cout << "#VALUE" << endl;
        // for (int i = half; i < size; i++) {
        //     cout << value[i] << " ";
        // }
        // cout << endl;
        // cout << "#ACTION" << endl;
        // for (int i = 1; i < half; i++) {
        //     cout << action[i] << " ";
        // }
        // cout << endl;
    }

private:
    void modifyRec(const ll int_index, const ll int_left, const ll int_right, const ll mod_left, const ll mod_right, const F& f)
    {
        if (mod_left <= int_left and int_right <= mod_right) {
            value[int_index] = act(f, value[int_index]);
            action[int_index] = compose(f, action[int_index]);
        } else if (int_right <= mod_left or mod_right <= int_left) {
            // Do nothing
        } else {
            modifyRec(2 * int_index, int_left, (int_left + int_right) / 2, 0, half, action[int_index]);
            modifyRec(2 * int_index, int_left, (int_left + int_right) / 2, mod_left, mod_right, f);
            modifyRec(2 * int_index + 1, (int_left + int_right) / 2, int_right, 0, half, action[int_index]);
            modifyRec(2 * int_index + 1, (int_left + int_right) / 2, int_right, mod_left, mod_right, f);
            value[int_index] = acc(value[2 * int_index], value[2 * int_index + 1]);
            action[int_index] = OpMonoid::identity();
        }
    }

    T accumulateRec(const ll int_index, const ll int_left, const ll int_right, const ll mod_left, const ll mod_right) const
    {
        if (mod_left <= int_left and int_right <= mod_right) {
            return value[int_index];
        } else if (int_right <= mod_left or mod_right <= int_left) {
            return AccMonoid::identity();
        } else {
            return act(action[int_index], acc(accumulateRec(2 * int_index, int_left, (int_left + int_right) / 2, mod_left, mod_right),
                                              accumulateRec(2 * int_index + 1, (int_left + int_right) / 2, int_right, mod_left, mod_right)));
        }
    }

    const ll data_num;  // Num of valid data on leaves.
    const ll height;
    const ll size;
    const ll half;
    vector<T> value;   // Tree for value(length: size)
    vector<F> action;  // Tree for action(length: half)
    bool has_lazy;

    const AccMonoid acc{};
    const OpMonoid compose{};
    const BaseAlgebra act{};
};

struct Min_Set {
    using T = ll;

    struct AccMonoid {
        T operator()(const T& a, const T& b) const { return min(a, b); }
        static constexpr T identity() { return INF<T>; }
    };

    struct OpMonoid {
        using T = ll;
        T operator()(const T& f1, const T& f2) const { return (f1 != INF<T>) ? f1 : f2; }
        static constexpr T identity() { return INF<T>; }
    };

    T operator()(const OpMonoid::T& f, const T& x) const { return (f != INF<T>) ? f : x; }
};

struct Sum_Plus {
    using X = ll;
    using T = pair<ll, ll>;  // (value, num)

    struct AccMonoid {
        T operator()(const T& a, const T& b) const { return make_pair(a.first + b.first, a.second + b.second); }
        static constexpr T identity() { return make_pair(0, 0); }  // Make sure to set the value (val, 1) to leaves!
    };

    struct OpMonoid {
        using T = X;
        T operator()(const T& f1, const T& f2) const { return f1 + f2; }
        static constexpr T identity() { return 0; }
    };

    T operator()(const OpMonoid::T& f, const T& x) const { return make_pair(x.first + x.second * f, x.second); }
};


int main()
{
    ll N;
    cin >> N;
    vector<ll> a(N);
    for (ll i = 0; i < N; i++) {
        cin >> a[i];
    }
    vector<ll> b(N);
    for (ll i = 0; i < N; i++) {
        b[i] = a[i];
    }
    sort(b.begin(), b.end());
    b.erase(unique(b.begin(), b.end()), b.end());
    unordered_map<ll, ll> zip;
    for (ll i = 0; i < b.size(); i++) {
        zip[b[i]] = i;
    }
    const ll size = b.size();
    SegmentTree<Min_Set> seg{size};
    SegmentTree<Sum_Plus> seg2{vector<pair<ll, ll>>(N, pair<ll, ll>{0, 1})};
    for (ll i = N - 1; i >= 0; i--) {
        seg.modify(0, zip[a[i]] + 1, i);
        seg2.modify(0, zip[a[i]] + 1, 1);
    }

    vector<ll> ans(N, 0);
    ll prev_l = 0;
    for (ll i = 0; i < size; i++) {
        const ll l = b[i];
        const ll cnt = seg2.get(i).first;
        const ll num = seg.get(i);
        assert(a[num] >= l);
        ans[num] += cnt * (l - prev_l);
        prev_l = l;
    }

    for (ll i = 0; i < N; i++) {
        cout << ans[i] << endl;
    }

    return 0;
}


Measured memory_bytes: 17800