title: Minimum Cost Make Array Size 1 Removing Larger Pairs
signature: func minimumCostMakeArraySize1RemovingLargerPairs(a []int, n int) int {
test_code: package main
  
  import (
      "fmt"
      "reflect"
      "math"
      "sort"
  )
  
  // SOLUTION CODE
  // ===================================
  PLACEHOLDER_CODE_BODY
  
  // TESTING CODE
  // ===================================
  func validateSolution(actual int, expected int) bool {
      return reflect.DeepEqual(actual,expected)
  }
  
  func driver(a []int, n int, expected int) string {
      if validateSolution(PLACEHOLDER_FN_NAME(a, n),expected) {
              return "PASSED"
      }
      return "FAILED"
  
  }
  
  func main() {
  
      // Use imports to avoid undefined errors
      var _ = reflect.DeepEqual
      _ = math.Abs
      _ = sort.Sort
      result := ""
      result = driver([]int{1, 2, 3, 4, 7, 8, 10, 10, 16, 20, 22, 22, 23, 23, 23, 27, 29, 32, 35, 39, 41, 46, 51, 53, 54, 59, 59, 60, 61, 69, 70, 70, 79, 79, 81, 84, 90, 91, 98}, 
  	25, 24)
      fmt.Printf("TEST-0...%s\n", result)
      
      result = driver([]int{-6, 10}, 
  	1, 0)
      fmt.Printf("TEST-1...%s\n", result)
      
      result = driver([]int{0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, 
  	15, 0)
      fmt.Printf("TEST-2...%s\n", result)
      
      result = driver([]int{20, 61, 92, 45, 75, 26, 83, 5, 85, 27, 39, 88, 36, 39, 83, 41, 56, 77, 39, 69, 72, 98, 39, 15, 29, 69, 64, 92, 96, 49, 59, 62, 53, 82, 40, 37, 29, 41}, 
  	23, 110)
      fmt.Printf("TEST-3...%s\n", result)
      
      result = driver([]int{-88, -60, -60, -58, -56, -56, -46, -44, -40, -38, -32, -28, -22, -18, -12, -4, -2, 10, 24, 24, 28, 38, 42, 46, 54, 64, 72, 74, 78, 96, 96}, 
  	26, -2200)
      fmt.Printf("TEST-4...%s\n", result)
      
      result = driver([]int{0, 1, 1, 1, 0, 1, 0, 1, 1, 1, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 1, 1, 1, 1, 1, 1, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 1, 1}, 
  	39, 0)
      fmt.Printf("TEST-5...%s\n", result)
      
      result = driver([]int{1, 4, 6, 9, 10, 12, 17, 17, 18, 21, 22, 26, 26, 31, 32, 33, 34, 39, 42, 43, 45, 46, 48, 50, 53, 53, 54, 55, 60, 61, 62, 63, 63, 64, 70, 70, 70, 71, 71, 78, 86, 88, 91, 92, 95, 95, 96, 97, 99}, 
  	28, 27)
      fmt.Printf("TEST-6...%s\n", result)
      
      result = driver([]int{-42, 44, -80, -60, 48, 66, 54, -76, 26, -74, -10, 46, -50, 42, -26, -24, -14, 36, -2, -26, 16, -10, 20, -88, -78}, 
  	19, -1584)
      fmt.Printf("TEST-7...%s\n", result)
      
      result = driver([]int{0, 0, 0, 0, 1, 1, 1, 1, 1, 1}, 
  	5, 0)
      fmt.Printf("TEST-8...%s\n", result)
      
      result = driver([]int{65, 32, 66, 82, 86, 98, 15, 33, 57, 3, 73, 45, 90, 82, 33, 99, 44, 76, 50, 89, 5, 7, 64}, 
  	22, 63)
      fmt.Printf("TEST-9...%s\n", result)
      
          
  }
source_py: def minimum_cost_make_array_size_1_removing_larger_pairs(a, n):
      return ((n - 1) * min(a))
source_cpp: int minimum_cost_make_array_size_1_removing_larger_pairs(vector<int> a, int n) {
    return ( n - 1 ) * ( * min_element(a.begin(), a.end()) );
  }