#K85387. Collectable Stamps

    ID: 36630 Type: Default 1000ms 256MiB

Collectable Stamps

Collectable Stamps

You are given N albums and a list of integers representing the number of stamps in each album. For each album i (0-indexed), you need to determine the total number of collectable stamps, defined as the sum of stamps from all previous albums that have a strictly lower number of stamps than the current album.

Formally, for each album index i, compute:

\( R_i = \sum_{j=0}^{i-1} \mathbf{1}_{\{albums[j] < albums[i]\}} \cdot albums[j] \)

where \( \mathbf{1}_{\{condition\}} \) is the indicator function, which is 1 if the condition is true and 0 otherwise.

Example: For N = 6 and albums = [4, 1, 3, 2, 5, 1], the output should be [0, 0, 1, 1, 10, 0].

inputFormat

The first line contains a single integer N, the number of albums. The second line contains N space-separated integers representing the number of stamps in each album.

outputFormat

Output a single line with N space-separated integers where the i-th integer represents the total collectable stamps for the i-th album.

## sample
6
4 1 3 2 5 1
0 0 1 1 10 0