#K90637. Redistribute Resources

    ID: 37797 Type: Default 1000ms 256MiB

Redistribute Resources

Redistribute Resources

You are given a number of storage units along with the resources they contain. Your task is to redistribute the resources among all storage units so that each unit ends up with the exact same number of resources.

Formally, let there be \( n \) storage units with resource values \( a_1, a_2, \dots, a_n \). Compute the total amount \( S = \sum_{i=1}^{n} a_i \). If \( S \) is divisible by \( n \) (i.e. \( S \mod n = 0 \)), then redistribute the resources equally so that each unit has \( \frac{S}{n} \) resources; otherwise, set each storage unit to \( -1 \) to indicate that equal distribution is impossible.

The input is provided through stdin and the answer should be printed to stdout in a single line where the resource values are separated by spaces.

inputFormat

The first line contains an integer \( n \) indicating the number of storage units. The second line contains \( n \) integers separated by spaces, where the \( i\text{-th} \) integer represents the resource count in the \( i\text{-th} \) storage unit.

outputFormat

Output a single line consisting of \( n \) space-separated integers. If redistribution is possible, output the redistributed value for every storage unit. Otherwise, output \(-1\) for each storage unit.

## sample
3
10 20 30
20 20 20