n = io.read('*n')
a = {}
for i = 1, n do a[i] = io.read('*n') end

max = -1
max_idx = {}
cnt = {}
for i = 1, n do
    if a[i] > max then
        max = a[i]
        max_idx[a[i]] = i
    end
    cnt[a[i]] = (cnt[a[i]] or 0) + 1
end

cnt_sorted = {}
for val, count in pairs(cnt) do
    cnt_sorted[#cnt_sorted + 1] = { val, count }
end
table.sort(cnt_sorted, function (a, b) return a[1] > b[1] end)

ans = {}
for i = 1, n do ans[i] = 0 end
accum, total = 0, 0
next_idx, next_ans = -1, 0
for i = 1, #cnt_sorted do
    local val, count = cnt_sorted[i][1], cnt_sorted[i][2]
    if max_idx[val] ~= nil then
        if next_idx ~= -1 then
            ans[next_idx] = accum - val * total - next_ans
            next_ans = accum - val * total
        end
        next_idx = max_idx[val]
    end
    accum = accum + val * count
    total = total + count
end
ans[next_idx] = accum - next_ans

for i = 1, n do print(ans[i]) end
