title: Maximum Sum Iarri Among Rotations Given Array
signature: maximumSumIarriAmongRotationsGivenArray :: [Integer] -> Integer -> Integer
  maximumSumIarriAmongRotationsGivenArray 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 ([11, 12, 16, 26, 29, 40, 54, 59, 65, 70, 71, 73, 78, 81, 87, 87, 88, 90, 95, 97]) (11) (3035) )
  
      printf "TEST-1...%s\n" (driver ([-46, -32, 54, 96, -72, -58, -36, -44, 26, -2, -68, 42, 90, 26, -92, -96, 88, -42, -18, 46, -70, 24, 0, 24, 34, 34, -52, 50, 94, -60, 64, 58]) (22) (592) )
  
      printf "TEST-2...%s\n" (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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) (33) (392) )
  
      printf "TEST-3...%s\n" (driver ([48, 2, 79, 98, 28, 17, 41, 47, 61, 76, 82, 5, 74, 4, 80, 51, 22, 45, 91, 75, 91, 93, 42, 45, 69, 98, 76, 74, 83, 17, 30, 88, 53, 25, 35, 19, 26]) (20) (10714) )
  
      printf "TEST-4...%s\n" (driver ([-88, -84, -82, -74, -44, -34, -32, -20, -20, -14, 6, 6, 10, 12, 16, 24, 32, 34, 38, 46, 54, 54, 56, 60, 82, 88, 90, 94, 98]) (24) (7026) )
  
      printf "TEST-5...%s\n" (driver ([0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1]) (7) (19) )
  
      printf "TEST-6...%s\n" (driver ([10, 14, 14, 14, 19, 20, 22, 26, 35, 36, 40, 53, 54, 55, 55, 57, 57, 67, 72, 72, 77, 78, 83, 84, 95, 96]) (16) (5149) )
  
      printf "TEST-7...%s\n" (driver ([-80, 18, -76, 48, -52, -38, 52, -82, 40, -44, -90, 86, -86, -36, -32, -2, 56, -12, -88, 14, -16, 8, 52, 24, 46, 56, 84, -36, 84, -60, 72, -46, 32, -16, -20, 68, -86, -62, 58, 8, 78, -52, 22, -28, -22, -42, 12, -48]) (30) (4226) )
  
      printf "TEST-8...%s\n" (driver ([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1]) (14) (46) )
  
      printf "TEST-9...%s\n" (driver ([20, 94, 36, 2, 50, 62, 84, 50, 66, 75, 1, 18, 41, 48, 72, 61, 86, 22, 54, 6, 71, 46, 92, 68, 59, 51, 89, 31, 58, 78, 82, 84]) (25) (16847) )
  
source_py: def maximum_sum_iarri_among_rotations_given_array(arr, n):
      res = (- sys.maxsize)
      for i in range(0, n):
          curr_sum = 0
          for j in range(0, n):
              index = int(((i + j) % n))
              curr_sum += (j * arr[index])
          res = max(res, curr_sum)
      return res
source_cpp: int maximum_sum_iarri_among_rotations_given_array(vector<int> arr, int n) {
    int res = INT_MIN;
    for ( int i = 0;
    i < n;
    i ++ ) {
      int curr_sum = 0;
      for ( int j = 0;
      j < n;
      j ++ ) {
        int index = ( i + j ) % n;
        curr_sum += j * arr [ index ];
      }
      res = max ( res, curr_sum );
    }
    return res;
  }