#K90727. Minimize Standard Deviation after Removal
Minimize Standard Deviation after Removal
Minimize Standard Deviation after Removal
You are given an array of integers. Your task is to remove exactly one element from the array so that the standard deviation of the remaining elements is minimized.
The standard deviation \(\sigma\) of an array of \(n\) elements \(x_1, x_2, \dots, x_n\) is defined as:
[ \sigma = \sqrt{\frac{1}{n} \sum_{i=1}^n (x_i - \mu)^2}, \quad \text{where } \mu = \frac{1}{n}\sum_{i=1}^n x_i ]
If the array contains less than two elements after removal, consider the standard deviation to be 0. The answer should be rounded to exactly six decimal places.
inputFormat
The first line contains an integer \(n\) (\(n \ge 1\)) representing the number of elements in the array. The second line contains \(n\) space-separated integers.
outputFormat
Output a single line containing the minimum possible standard deviation of the remaining array, rounded to six decimal places.
## sample5
1 2 3 4 5
1.118034
</p>