Minimum cost to make array size 1 by removing larger of pairs | function to calculate the minimum cost ; Minimum cost is n - 1 multiplied with minimum element . ; Driver Code
< ? php function cost ( $ a , $ n ) { return ( $ n - 1 ) * ( min ( $ a ) ) ; } $ a = array ( 4 , 3 , 2 ) ; $ n = count ( $ a ) ; echo cost ( $ a , $ n ) ; ? >