N = int(eval(input()))

A = [int(a) for a in input().split()]



S = sum(A)

for i in range(N):

    A[i] = [A[i], i+1]



A.sort(reverse=True)

ans = [0]*(N+1)

i = 0

num = N+1

while i < N-1:

    num = min(num, A[i][1])

    while i < N-1 and A[i][0] == A[i+1][0]:

        num = min(num, A[i+1][1])

        i += 1

    if i == N-1:

        break

    ans[num] += (i+1)*(A[i][0]-A[i+1][0])

    i += 1



ans[1] += S-sum(ans)

for i in range(1, N+1):

    print((ans[i]))
N = int(eval(input()))

A = [int(a) for a in input().split()]



ans = [0]*N

num = 0

B = sorted(A)

j = 0

for i in range(N):

    cnt = 0

    while j < N and B[j] <= A[i]:

        cnt += max(0, B[j]-num)

        j += 1

    ans[i] = cnt + max(0, (N-j)*(A[i]-num))

    num = max(num, A[i])



for a in ans:

    print(a)
N = int(eval(input()))
A = [int(a) for a in input().split()]
S = sum(A)
for i in range(N):
    A[i] = [A[i], i + 1]
A.sort(reverse=True)
ans = [0] * (N + 1)
i = 0
num = N + 1
while i < N - 1:
    num = min(num, A[i][1])
    while i < N - 1 and A[i][0] == A[i + 1][0]:
        num = min(num, A[i + 1][1])
        i += 1
    if i == N - 1:
        break
    ans[num] += (i + 1) * (A[i][0] - A[i + 1][0])
    i += 1
ans[1] += S - sum(ans)
for i in range(1, N + 1):
    print((ans[i]))

N = int(eval(input()))
A = [int(a) for a in input().split()]
ans = [0] * N
num = 0
B = sorted(A)
j = 0
for i in range(N):
    cnt = 0
    while j < N and B[j] <= A[i]:
        cnt += max(0, B[j] - num)
        j += 1
    ans[i] = cnt + max(0, (N - j) * (A[i] - num))
    num = max(num, A[i])
for a in ans:
    print(a)

-S = sum(A) +ans = [0] * N +num = 0 +B = sorted(A) +j = 0 -    A[i] = [A[i], i + 1] -A.sort(reverse=True) -ans = [0] * (N + 1) -i = 0 -num = N + 1 -while i < N - 1: -    num = min(num, A[i][1]) -    while i < N - 1 and A[i][0] == A[i + 1][0]: -        num = min(num, A[i + 1][1]) -        i += 1 -    if i == N - 1: -        break -    ans[num] += (i + 1) * (A[i][0] - A[i + 1][0]) -    i += 1 -ans[1] += S - sum(ans) -for i in range(1, N + 1): -    print((ans[i])) +    cnt = 0 +    while j < N and B[j] <= A[i]: +        cnt += max(0, B[j] - num) +        j += 1 +    ans[i] = cnt + max(0, (N - j) * (A[i] - num)) +    num = max(num, A[i]) +for a in ans: +    print(a)