import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, core.stdc.stdio, std.bitmanip;

void main() {
    auto N = readln.chomp.to!int;
    auto A = readln.split.map!(to!long).array;
    auto ans = new long[](N);


    int[long] comp;
    auto comp_rev = A.dup.sort().uniq.array;
    foreach (i; 0..comp_rev.length) {
        comp[comp_rev[i]] = i.to!int;
    }
    long mx = comp.reduce!(max);

    auto B = new int[](N);
    foreach (i; 0..N) {
        B[i] = comp[A[i]];
    }


    auto d = new long[](mx+1);
    fill(d, -1);
    foreach (i; 0..N) {
        if (d[B[i]] == -1) d[B[i]] = i;
    }


    auto st = new SegmentTree((mx+1).to!int);
    auto tmp_mx = mx;

    for (int i = N-1; i > 0; i--) {
        st.add(B[i], 1);
        if (i == d[tmp_mx]) {
            auto sub = (comp_rev[B[i]] - comp_rev[B[i]-1]) * st.sum(B[i], mx.to!int);
            ans[i] = sub;
            tmp_mx -= 1;
        }
    }

    ans[0] = A.sum - ans.sum;
    ans.each!(writeln);
}

class SegmentTree {
    long[] table;
    int size;

    this(int n) {
        assert(bsr(n) < 29);
        size = 1 << (bsr(n) + 2);
        table = new long[](size);
    }

    void add(int pos, long num) {
        return add(pos, num, 0, 0, size/2-1);
    }

    void add(int pos, long num, int i, int left, int right) {
        table[i] += num;
        if (left == right)
            return;
        auto mid = (left + right) / 2;
        if (pos <= mid)
            add(pos, num, i*2+1, left, mid);
        else
            add(pos, num, i*2+2, mid+1, right);
    }

    long sum(int pl, int pr) {
        return sum(pl, pr, 0, 0, size/2-1);
    }

    long sum(int pl, int pr, int i, int left, int right) {
        if (pl > right || pr < left)
            return 0;
        else if (pl <= left && right <= pr)
            return table[i];
        else
            return
                sum(pl, pr, i*2+1, left, (left+right)/2) +
                sum(pl, pr, i*2+2, (left+right)/2+1, right);
    }
}
