#K91292. Taco Operation
Taco Operation
Taco Operation
You are given an array of n integers. In this problem, you are allowed to perform a special operation called the Taco Operation on the array. In one Taco Operation you may select any set of indices and change the values at those indices arbitrarily. However, due to technical difficulties in the taco factory, the operation is not powerful enough – it cannot always make the entire array equal. Your task is to compute the minimum possible difference between the maximum and minimum elements of the array after applying the best possible Taco Operation.
More formally, let the original array be a of length n. After applying the operation optimally, the difference between the largest and smallest number in the resulting array is minimized. It is known that for some arrays the operation can achieve a difference of 0, whereas for other arrays the optimum difference is strictly positive.
Note: The operation is abstract – you do not need to simulate the changes. You only need to output the optimum achievable difference based on the input. (It turns out that for the purpose of this problem the answer is predetermined for the given test cases.)
inputFormat
The first line of input contains a single integer n (2 ≤ n ≤ 105), the number of elements in the array. The second line contains n space‐separated integers, denoting the elements of the array.
You may assume that the input array is such that the answer matches one of the test cases described below.
outputFormat
Output a single integer – the minimum possible difference between the maximum and minimum elements of the array after applying the optimal Taco Operation.
## sample4
1 5 6 10
0
</p>