title: Maximize Sum Arrii
signature: class Solution {
  
      public int MaximizeSumArrii(List<int> arr, int n) {
test_code: using System;
  using System.Numerics;
  using System.Diagnostics;
  using System.Collections.Generic;
  using System.Linq;
  using System.Text;
  using System.Security.Cryptography;
  using System.Web.UI;
  using System.Web.Script.Serialization;
  
  // SOLUTION CODE
  // ============================================
  PLACEHOLDER_CODE_BODY
  
  // TESTING CODE 
  // ============================================
  namespace EvaluatePrediction {
      class TestRunner {
          public bool ValidateSolution(int actual, int expected){
              return new JavaScriptSerializer().Serialize(actual) == new JavaScriptSerializer().Serialize(expected);
          }
  
          public string driver(List<int> arr, int n, int expected){
              try{
                PLACEHOLDER_CLS_NAME solution_cls = new PLACEHOLDER_CLS_NAME();
                int pred_result = solution_cls.PLACEHOLDER_FN_NAME(arr, n); 
                if (ValidateSolution(
                      pred_result,
                      expected)){
                  return "PASSED";
                }
                return "FAILED";
              } 
              catch (Exception exception_obj)
              {
                return exception_obj.GetType().FullName;
              }
          }
          static void Main(string[] args) {
              TestRunner runner = new TestRunner();
              String result;
              result = runner.driver(
                  new List<int>{2, 3, 4, 6, 7, 8, 9, 11, 19, 23, 24, 30, 31, 31, 32, 41, 43, 43, 46, 47, 50, 50, 51, 53, 57, 63, 63, 69, 73, 74, 79, 80, 81, 81, 85, 86, 88, 92, 93, 95, 98, 99}, 22, 
                  8185
              );
              Console.WriteLine(string.Format(
                  "TEST-0...{0}",
                  result)
              );result = runner.driver(
                  new List<int>{-98, -98, -82, -80, -78, -76, -74, -68, -62, -58, -58, -52, -42, -42, -40, -34, -16, -10, -10, -6, 10, 12, 20, 32, 52, 62, 66, 68, 72, 76, 76, 80, 90, 90, 90, 90, 92, 98}, 24, 
                  -5496
              );
              Console.WriteLine(string.Format(
                  "TEST-1...{0}",
                  result)
              );result = runner.driver(
                  new List<int>{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1}, 13, 
                  0
              );
              Console.WriteLine(string.Format(
                  "TEST-2...{0}",
                  result)
              );result = runner.driver(
                  new List<int>{8, 13, 14, 42, 44, 44, 44, 45, 47, 52, 58, 79, 98, 99}, 11, 
                  2566
              );
              Console.WriteLine(string.Format(
                  "TEST-3...{0}",
                  result)
              );result = runner.driver(
                  new List<int>{-90, -88, -68, -66, -46, -42, -40, -20, -16, 4, 8, 8, 8, 20, 28, 52, 84, 98}, 14, 
                  -764
              );
              Console.WriteLine(string.Format(
                  "TEST-4...{0}",
                  result)
              );result = runner.driver(
                  new List<int>{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, 13, 
                  23
              );
              Console.WriteLine(string.Format(
                  "TEST-5...{0}",
                  result)
              );result = runner.driver(
                  new List<int>{5, 6, 7, 9, 11, 13, 16, 19, 22, 25, 26, 27, 28, 29, 32, 32, 32, 33, 36, 40, 43, 43, 47, 49, 51, 51, 52, 53, 59, 61, 63, 65, 66, 66, 67, 72, 73, 73, 75, 76, 80, 86, 87, 89, 89, 91, 96, 98, 99}, 42, 
                  48954
              );
              Console.WriteLine(string.Format(
                  "TEST-6...{0}",
                  result)
              );result = runner.driver(
                  new List<int>{-98, -96, -90, -78, -66, -52, -48, -38, -34, -32, -30, -26, -24, -22, -20, -20, -14, -14, -12, -12, -8, -6, -4, 2, 6, 26, 28, 32, 32, 34, 40, 40, 48, 52, 54, 64, 64, 68, 70, 76, 88, 92, 96}, 39, 
                  16394
              );
              Console.WriteLine(string.Format(
                  "TEST-7...{0}",
                  result)
              );result = runner.driver(
                  new List<int>{0, 0, 1, 1}, 3, 
                  2
              );
              Console.WriteLine(string.Format(
                  "TEST-8...{0}",
                  result)
              );result = runner.driver(
                  new List<int>{18, 20, 21, 32, 34, 44, 47, 49, 49, 49, 62, 71, 75, 84, 84, 88, 88}, 8, 
                  1139
              );
              Console.WriteLine(string.Format(
                  "TEST-9...{0}",
                  result)
              );
          }
      }
  }
  
source_py: def maximize_sum_arrii(arr, n):
      arr.sort()
      sum = 0
      for i in range(n):
          sum += (arr[i] * i)
      return sum
source_cpp: int maximize_sum_arrii(vector<int> arr, int n) {
    sort(arr.begin(), arr.end());
    int sum = 0;
    for ( int i = 0;
    i < n;
    i ++ ) sum += ( arr [ i ] * i );
    return sum;
  }