Ruby code to find the index of an element with the maximal deviation from the mean value of the array