title: Minimum Cost Make Array Size 1 Removing Larger Pairs
signature: minimum_cost_make_array_size_1_removing_larger_pairs <- function(a, n) {
test_code: 
  
  
  # SOLUTION CODE
  # ============================================
  PLACEHOLDER_CODE_BODY
  
  # TESTING CODE 
  # ============================================
  validate_solution <- function(actual, expected) {
      toString(actual)==toString(expected)
  }
  
  driver <- function(a, n, expected){
      if (validate_solution(PLACEHOLDER_FN_NAME(a, n), expected)){
          "PASSED"
      } else{
          "FAILED"
      }
  }
  
  main <- function() {
      cat(sprintf("TEST-0...%s\n",driver(
          list(1L, 2L, 3L, 4L, 7L, 8L, 10L, 10L, 16L, 20L, 22L, 22L, 23L, 23L, 23L, 27L, 29L, 32L, 35L, 39L, 41L, 46L, 51L, 53L, 54L, 59L, 59L, 60L, 61L, 69L, 70L, 70L, 79L, 79L, 81L, 84L, 90L, 91L, 98L), 25L, 
          24L
      )))
  
      cat(sprintf("TEST-1...%s\n",driver(
          list(-6L, 10L), 1L, 
          0L
      )))
  
      cat(sprintf("TEST-2...%s\n",driver(
          list(0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L), 15L, 
          0L
      )))
  
      cat(sprintf("TEST-3...%s\n",driver(
          list(20L, 61L, 92L, 45L, 75L, 26L, 83L, 5L, 85L, 27L, 39L, 88L, 36L, 39L, 83L, 41L, 56L, 77L, 39L, 69L, 72L, 98L, 39L, 15L, 29L, 69L, 64L, 92L, 96L, 49L, 59L, 62L, 53L, 82L, 40L, 37L, 29L, 41L), 23L, 
          110L
      )))
  
      cat(sprintf("TEST-4...%s\n",driver(
          list(-88L, -60L, -60L, -58L, -56L, -56L, -46L, -44L, -40L, -38L, -32L, -28L, -22L, -18L, -12L, -4L, -2L, 10L, 24L, 24L, 28L, 38L, 42L, 46L, 54L, 64L, 72L, 74L, 78L, 96L, 96L), 26L, 
          -2200L
      )))
  
      cat(sprintf("TEST-5...%s\n",driver(
          list(0L, 1L, 1L, 1L, 0L, 1L, 0L, 1L, 1L, 1L, 0L, 1L, 0L, 0L, 0L, 1L, 0L, 0L, 1L, 0L, 0L, 1L, 1L, 1L, 1L, 1L, 1L, 0L, 1L, 0L, 0L, 1L, 1L, 1L, 0L, 0L, 0L, 1L, 1L, 0L, 0L, 0L, 1L, 0L, 1L, 1L), 39L, 
          0L
      )))
  
      cat(sprintf("TEST-6...%s\n",driver(
          list(1L, 4L, 6L, 9L, 10L, 12L, 17L, 17L, 18L, 21L, 22L, 26L, 26L, 31L, 32L, 33L, 34L, 39L, 42L, 43L, 45L, 46L, 48L, 50L, 53L, 53L, 54L, 55L, 60L, 61L, 62L, 63L, 63L, 64L, 70L, 70L, 70L, 71L, 71L, 78L, 86L, 88L, 91L, 92L, 95L, 95L, 96L, 97L, 99L), 28L, 
          27L
      )))
  
      cat(sprintf("TEST-7...%s\n",driver(
          list(-42L, 44L, -80L, -60L, 48L, 66L, 54L, -76L, 26L, -74L, -10L, 46L, -50L, 42L, -26L, -24L, -14L, 36L, -2L, -26L, 16L, -10L, 20L, -88L, -78L), 19L, 
          -1584L
      )))
  
      cat(sprintf("TEST-8...%s\n",driver(
          list(0L, 0L, 0L, 0L, 1L, 1L, 1L, 1L, 1L, 1L), 5L, 
          0L
      )))
  
      cat(sprintf("TEST-9...%s\n",driver(
          list(65L, 32L, 66L, 82L, 86L, 98L, 15L, 33L, 57L, 3L, 73L, 45L, 90L, 82L, 33L, 99L, 44L, 76L, 50L, 89L, 5L, 7L, 64L), 22L, 
          63L
      )))
  
  }
  
  main()
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()) );
  }