#C11801. Minimum Total Time to Collect Fruits
Minimum Total Time to Collect Fruits
Minimum Total Time to Collect Fruits
You are given \( M \), the number of houses, and a list of \( M \) integers where each integer represents the number of fruits in a house.
Your task is to determine the minimum total time required to move from the house with the fewest fruits to the house with the most fruits. Note that if you sort the list of fruit counts in non-decreasing order, the total time is simply the difference between the largest and smallest value:
\( \text{time} = a_{\text{max}} - a_{\text{min}} \)
You can assume that the list always contains at least two houses.
inputFormat
The first line contains an integer \( M \) representing the number of houses.
The second line contains \( M \) space-separated integers representing the number of fruits in each house.
outputFormat
Output a single integer which is the minimum total time required, computed as the difference between the highest and lowest number of fruits.
## sample5
3 1 6 2 5
5