#C4224. Minimum Days to Equalize Plant Height
Minimum Days to Equalize Plant Height
Minimum Days to Equalize Plant Height
Given a list of plant heights, determine the minimum number of days required to water all the plants so that they all reach the same height as the tallest one. Each day, you can water any one plant, which increases its height by 1 unit.
Formally, if the heights of the plants are given by \(h_1, h_2, \dots, h_n\) and the maximum height is \(H = \max\{h_1, h_2, \dots, h_n\}\), then the minimum days required is shown by the formula:
\[\text{Days} = \sum_{i=1}^{n} (H - h_i)\]
Your task is to compute this number.
inputFormat
The first line of input contains an integer \(n\) representing the number of plants. The second line contains \(n\) space-separated integers, where each integer represents the height of a plant.
outputFormat
Output a single integer which is the minimum number of days required to equalize all the plant heights.
## sample3
5 5 5
0