Maximum sum of i * arr [ i ] among all rotations of a given array | A Naive C # program to find maximum sum rotation ; Returns maximum value of i * arr [ i ] ; Initialize result ; Consider rotation beginning with i for all possible values of i . ; Initialize sum of current rotation ; Compute sum of all values . We don 't  acutally rotation the array, but compute  sum by finding ndexes when arr[i] is  first element ; Update result if required ; Driver code
using System ; class GFG { static int maxSum ( int [ ] arr , int n ) { int res = int . MinValue ; 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 = Math . Max ( res , curr_sum ) ; } return res ; } public static void Main ( ) { int [ ] arr = { 8 , 3 , 1 , 2 } ; int n = arr . Length ; Console . WriteLine ( maxSum ( arr , n ) ) ; } }