This function returns the minimum cost of the array
function getMinCost ( arr , n ) { let min_ele = Number . MAX_VALUE ; for ( let i = 0 ; i < n ; i ++ ) { min_ele = Math . min ( min_ele , arr [ i ] ) ; } return min_ele * ( n - 1 ) ; }