title: Maximize Sum Consecutive Differences Circular Array
signature: maximizeSumConsecutiveDifferencesCircularArray :: [Integer] -> Integer -> Integer
  maximizeSumConsecutiveDifferencesCircularArray arr n = 
test_code: import Text.Printf
  import Control.Exception (catch, SomeException)
  import Data.Typeable
  import qualified Data.List as List
  import qualified Data.Map as Map
  import qualified Data.Set as Set
  
  -- SOLUTION CODE
  -- ============================================
  
  PLACEHOLDER_CODE_BODY
  
  -- TESTING CODE 
  -- ============================================
  validateSolution :: Integer -> Integer -> Bool
  validateSolution actual expected = do
      actual == expected
  
  
  driver :: [Integer] -> Integer -> Integer -> String
  driver arr n expected = do
      if (validateSolution (PLACEHOLDER_FN_NAME arr n) expected)
          then "PASSED"
      else "FAILED"
  
  main = do
      printf "TEST-0...%s\n" (driver ([8, 9, 12, 13, 17, 21, 24, 29, 37, 37, 39, 40, 41, 45, 49, 50, 53, 54, 56, 59, 60, 60, 70, 71, 72, 74, 77, 77, 78, 85, 89, 89, 90, 90, 95, 98, 98]) (34) (1454) )
  
      printf "TEST-1...%s\n" (driver ([-92, -84, -84, -84, -84, -80, -80, -80, -64, -52, -40, -32, -20, -18, -16, 0, 6, 14, 20, 26, 28, 30, 32, 32, 44, 48, 48, 52, 54, 66, 76, 78, 88, 92, 94, 96]) (24) (1980) )
  
      printf "TEST-2...%s\n" (driver ([0, 0, 0, 1, 1, 1]) (3) (0) )
  
      printf "TEST-3...%s\n" (driver ([7, 47, 53, 59, 80, 84, 96]) (5) (170) )
  
      printf "TEST-4...%s\n" (driver ([-88, -80, -68, -62, -60, -60, -48, -46, -44, -38, -16, -16, 0, 0, 2, 8, 20, 36, 40, 40, 44, 54, 60, 68, 70, 82, 82, 84, 92, 94, 96]) (29) (2812) )
  
      printf "TEST-5...%s\n" (driver ([0, 0, 0, 0, 0, 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, 1, 1, 1, 1, 1, 1, 1, 1, 1]) (32) (20) )
  
      printf "TEST-6...%s\n" (driver ([2, 5, 10, 11, 13, 14, 15, 17, 17, 23, 23, 24, 27, 27, 28, 29, 30, 40, 42, 43, 46, 47, 51, 52, 57, 64, 65, 73, 74, 75, 76, 77, 81, 81, 82, 87, 89, 93, 95, 95, 99]) (35) (1542) )
  
      printf "TEST-7...%s\n" (driver ([-94, -92, -84, -84, -76, -72, -72, -72, -54, -48, -38, -22, -16, -12, 2, 2, 12, 20, 20, 24, 26, 26, 26, 26, 30, 38, 48, 50, 84, 86]) (21) (1608) )
  
      printf "TEST-8...%s\n" (driver ([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 1, 1, 1]) (37) (20) )
  
      printf "TEST-9...%s\n" (driver ([7, 8, 27, 31, 37, 46, 46, 52, 53, 53, 56, 57, 57, 73, 73, 74, 80, 84, 97]) (13) (344) )
  
source_py: def maximize_sum_consecutive_differences_circular_array(arr, n):
      sum = 0
      arr.sort()
      for i in range(0, int((n / 2))):
          sum -= (2 * arr[i])
          sum += (2 * arr[((n - i) - 1)])
      return sum
source_cpp: int maximize_sum_consecutive_differences_circular_array(vector<int> arr, int n) {
    int sum = 0;
    sort(arr.begin(), arr.end());
    for ( int i = 0;
    i < n / 2;
    i ++ ) {
      sum -= ( 2 * arr [ i ] );
      sum += ( 2 * arr [ n - i - 1 ] );
    }
    return sum;
  }