title: Minimum Cost Connect Weighted Nodes Represented Array
signature: function minimumCostConnectWeightedNodesRepresentedArray(a: Array<number>, n: number): number {
source_py: def minimum_cost_connect_weighted_nodes_represented_array(a, n):
      mn = sys.maxsize
      sum = 0
      for i in range(n):
          mn = min(a[i], mn)
          sum += a[i]
      return (mn * (sum - mn))
source_cpp: int minimum_cost_connect_weighted_nodes_represented_array(vector<int> a, int n) {
    int mn = INT_MAX;
    int sum = 0;
    for ( int i = 0;
    i < n;
    i ++ ) {
      mn = min ( a [ i ], mn );
      sum += a [ i ];
    }
    return mn * ( sum - mn );
  }
question_info.test_list: [{"idx": 0, "outputs": 4548, "inputs": {"a": [3, 8, 14, 15, 17, 17, 19, 21, 22, 23, 29, 32, 36, 37, 43, 45, 46, 47, 47, 53, 57, 57, 70, 71, 72, 76, 81, 82, 90, 95, 96, 98, 99], "n": 32}}, {"idx": 1, "outputs": -736, "inputs": {"a": [94, -18, 50, 94, -74, -50, -44, -92, -58, 14, -66, -78], "n": 10}}, {"idx": 2, "outputs": 0, "inputs": {"a": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], "n": 24}}, {"idx": 3, "outputs": 270, "inputs": {"a": [15, 18, 64, 28], "n": 2}}, {"idx": 4, "outputs": 40896, "inputs": {"a": [-96, -88, -88, -84, -82, -78, -78, -60, -58, -56, -54, -52, -48, -44, -28, -26, -14, -12, 6, 10, 10, 14, 14, 50, 52, 54, 60, 62, 62, 64, 66, 70, 72, 72, 78, 80, 84], "n": 31}}, {"idx": 5, "outputs": 0, "inputs": {"a": [0, 1, 1, 0, 1, 1, 1, 1], "n": 6}}, {"idx": 6, "outputs": 2652, "inputs": {"a": [3, 10, 14, 14, 15, 16, 18, 20, 21, 30, 31, 33, 35, 39, 46, 48, 59, 59, 61, 77, 78, 79, 81, 83, 85, 92, 97, 97, 99], "n": 23}}, {"idx": 7, "outputs": 9936, "inputs": {"a": [4, -32, 68, -48, 54, 24, 78, 98, -70, 44, -82, -92, -16, -92, -70, 52, -58, -62, -58, 32, 14, -4, 80, -78, -26, -24, -8], "n": 18}}, {"idx": 8, "outputs": 0, "inputs": {"a": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], "n": 35}}, {"idx": 9, "outputs": 1808, "inputs": {"a": [82, 74, 53, 91, 81, 88, 42, 62, 38, 43, 29, 60, 43, 44, 19, 28, 20, 1, 5, 94, 18, 77, 52, 38, 55, 1, 10, 29, 34, 91, 64, 80, 81, 39, 4, 47, 30, 62, 58, 66, 73, 52, 62, 9, 36, 49], "n": 38}}]
question_info.entry_cls_name: Solution
question_info.test_code: 
  
  // SOLUTION CODE
  // ============================================
  PLACEHOLDER_CODE_BODY
  
  // TESTING CODE 
  // ============================================
  function convertToString(value: any): string{
      return JSON.stringify(value, function (key, val) {
          if (val instanceof Set) {
              return Array.from(val);
          } return val;});
  }
  
  function validateSolution(actual: number, expected: number): boolean {
      return convertToString(actual) === convertToString(expected);
  }
  
  function driver(a: Array<number>, n: number, expected:number): string {
      try{
          if (validateSolution(PLACEHOLDER_FN_NAME(a, n),expected)){
              return "PASSED";
          }
          return "FAILED";
      } catch (error) {
        return error.name;
      }
      
  }
      
  function main(){
    let result = '';
    result = driver([3, 8, 14, 15, 17, 17, 19, 21, 22, 23, 29, 32, 36, 37, 43, 45, 46, 47, 47, 53, 57, 57, 70, 71, 72, 76, 81, 82, 90, 95, 96, 98, 99], 32, 4548);
    console.log(`TEST-0...${result}`);
  
    result = driver([94, -18, 50, 94, -74, -50, -44, -92, -58, 14, -66, -78], 10, -736);
    console.log(`TEST-1...${result}`);
  
    result = driver([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], 24, 0);
    console.log(`TEST-2...${result}`);
  
    result = driver([15, 18, 64, 28], 2, 270);
    console.log(`TEST-3...${result}`);
  
    result = driver([-96, -88, -88, -84, -82, -78, -78, -60, -58, -56, -54, -52, -48, -44, -28, -26, -14, -12, 6, 10, 10, 14, 14, 50, 52, 54, 60, 62, 62, 64, 66, 70, 72, 72, 78, 80, 84], 31, 40896);
    console.log(`TEST-4...${result}`);
  
    result = driver([0, 1, 1, 0, 1, 1, 1, 1], 6, 0);
    console.log(`TEST-5...${result}`);
  
    result = driver([3, 10, 14, 14, 15, 16, 18, 20, 21, 30, 31, 33, 35, 39, 46, 48, 59, 59, 61, 77, 78, 79, 81, 83, 85, 92, 97, 97, 99], 23, 2652);
    console.log(`TEST-6...${result}`);
  
    result = driver([4, -32, 68, -48, 54, 24, 78, 98, -70, 44, -82, -92, -16, -92, -70, 52, -58, -62, -58, 32, 14, -4, 80, -78, -26, -24, -8], 18, 9936);
    console.log(`TEST-7...${result}`);
  
    result = driver([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], 35, 0);
    console.log(`TEST-8...${result}`);
  
    result = driver([82, 74, 53, 91, 81, 88, 42, 62, 38, 43, 29, 60, 43, 44, 19, 28, 20, 1, 5, 94, 18, 77, 52, 38, 55, 1, 10, 29, 34, 91, 64, 80, 81, 39, 4, 47, 30, 62, 58, 66, 73, 52, 62, 9, 36, 49], 38, 1808);
    console.log(`TEST-9...${result}`);
  
  };
  
  main();
question_info.extension: ts
question_info.entry_fn_name: minimumCostConnectWeightedNodesRepresentedArray
question_info.test_case_ids: 0 1 2 3 4 5 6 7 8 9
question_info.commands: tsc --target es2020 --lib es5,dom,es2015,es2020 __FILENAME__
question_info.commands: node __FILENAME__.js