Minimize Cost with Replacement with other allowed | C # Program for the above approach ; This function returns the minimum cost of the array ; Driver code
using System ; using System . Linq ; class GfG { public static int getMinCost ( int [ ] arr , int n ) { int min_ele = arr . Min ( ) ; return min_ele * ( n - 1 ) ; } public static void Main ( String [ ] args ) { int [ ] arr = { 4 , 2 , 5 } ; int n = arr . Length ; Console . WriteLine ( getMinCost ( arr , n ) ) ; } }