Minimum cost to make array size 1 by removing larger of pairs | C # program to find minimum cost to reduce array size to 1 , ; function to calculate the minimum cost ; Minimum cost is n - 1 multiplied with minimum element . ; Driver code .
using System ; using System . Linq ; public class GFG { static int cost ( int [ ] a , int n ) { return ( n - 1 ) * a . Min ( ) ; } static public void Main ( ) { int [ ] a = { 4 , 3 , 2 } ; int n = a . Length ; Console . WriteLine ( cost ( a , n ) ) ; } }