title: Maximum Area Rectangle Picking Four Sides Array
signature: function maximum_area_rectangle_picking_four_sides_array(arr, n)
test_code: using Printf
  
  # SOLUTION CODE
  # ============================================
  PLACEHOLDER_CODE_BODY
  
  # TESTING CODE 
  # ============================================
  function validate_solution(actual, expected)
      return actual == expected
  end
  
  function driver(arr, n, expected)
      try
  
          if validate_solution(PLACEHOLDER_FN_NAME(arr, n), expected)
              return "PASSED";
          end
          return "FAILED";
      catch exception_obj
          return string(Base.typename(typeof(exception_obj)).wrapper);
      end
  end
  
  function main()
      
      result = driver([99, 96, 95, 95, 92, 84, 83, 82, 81, 74, 72, 68, 67, 52, 51, 51, 49, 47, 44, 40, 36, 25, 24, 17, 16, 14, 12, 11, 9, 8, 6, 5, 1], 27, 4845);
      @printf("TEST-0...%s\n",result);
      
      result = driver([-32, -54, -82, -92], 2, 0);
      @printf("TEST-1...%s\n",result);
      
      result = driver([1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 15, 1);
      @printf("TEST-2...%s\n",result);
      
      result = driver([99, 96, 96, 94, 68, 65, 62, 60, 45, 44, 30, 26, 17, 17, 16, 15, 2], 8, 0);
      @printf("TEST-3...%s\n",result);
      
      result = driver([98, 94, 82, 82, 74, 66, 66, 56, 54, 46, 16, -28, -34, -42, -50, -52, -78, -82, -88], 15, 5412);
      @printf("TEST-4...%s\n",result);
      
      result = driver([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 18, 1);
      @printf("TEST-5...%s\n",result);
      
      result = driver([97, 96, 93, 87, 85, 85, 75, 68, 65, 65, 64, 63, 62, 58, 56, 52, 49, 44, 43, 38, 33, 30, 29, 28, 27, 25, 24, 23, 14, 14, 13, 10, 8, 8, 8, 6, 1], 20, 5525);
      @printf("TEST-6...%s\n",result);
      
      result = driver([78, 78, 76, 70, 60, 54, 50, 32, 16, 16, 6, -6, -20, -56, -64, -68, -70, -90, -90, -92], 19, 1248);
      @printf("TEST-7...%s\n",result);
      
      result = driver([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 30, 1);
      @printf("TEST-8...%s\n",result);
      
      result = driver([94, 94, 94, 90, 84, 82, 75, 71, 57, 55, 53, 51, 51, 43, 35, 31, 30, 29, 22, 18, 14, 10, 7, 5, 4], 22, 4794);
      @printf("TEST-9...%s\n",result);
      
  end
  
  main()
source_py: def maximum_area_rectangle_picking_four_sides_array(arr, n):
      arr.sort(reverse=True)
      dimension = [0, 0]
      i = 0
      j = 0
      while ((i < (n - 1)) and (j < 2)):
          if (arr[i] == arr[(i + 1)]):
              dimension[j] = arr[i]
              j += 1
              i += 1
          i += 1
      return (dimension[0] * dimension[1])
source_cpp: int maximum_area_rectangle_picking_four_sides_array(vector<int> arr, int n) {
    sort(arr.begin(), arr.end(), greater < int > ( ) );
    int dimension [ 2 ] = {
      0, 0 };
      for ( int i = 0, j = 0;
      i < n - 1 && j < 2;
      i ++ ) if ( arr [ i ] == arr [ i + 1 ] ) dimension [ j ++ ] = arr [ i ++ ];
      return ( dimension [ 0 ] * dimension [ 1 ] );
    }