#K57607. Equalizing Tree Heights

    ID: 30458 Type: Default 1000ms 256MiB

Equalizing Tree Heights

Equalizing Tree Heights

You are given a collection of trees with various heights. In each year, the height difference between the tallest and the shortest trees indicates the number of years required for the shortest tree to catch up if it grows by 1 unit per year. More formally, the number of years needed is given by (\text{years} = \max(\text{heights}) - \min(\text{heights})).

Determine the minimum number of years required for all trees to have equal height.

inputFormat

The input consists of two lines:
1. The first line contains an integer ( n ), the number of trees.
2. The second line contains ( n ) space-separated integers representing the heights of the trees.

outputFormat

Output a single integer representing the minimum number of years required for all trees to become of equal height.## sample

3
4 7 5
3