cswork / OAOpen practice workspace

Akuna CapitalOA #12

Array Challenge (QR Intern)

Estimated EasyJudge-ready

Topics (AI-labelled)Prefix & RangesBits & Math

For each position i of the array, check every j<i from left to right: if the left value is greater than the current value, subtract the absolute difference; if the left value is less than or equal to the current value, add the absolute difference. Output the accumulated counter for each position.

Input

The first line contains n; the second line contains n integers arr[i]. The original gives no value constraints; this site adds 1≤n≤100000, −10^9≤arr[i]≤10^9.

Output

Output n integers, the counter of each position in the original array order.

Example 1

Input:

3
2 4 3

Output:

0 2 0

Example 2

Input:

1
7

Output:

0

Example 3

Input:

4
3 3 1 5

Output:

0 0 -4 8

Editorial

Loading solution…