Compute sum of all values . We don 't  acutally rotation the array, but compute  sum by finding ndexes when arr[i] is  first element
for ( int j = 0 ; j < n ; j ++ ) { int index = ( i + j ) % n ; curr_sum += j * arr [ index ] ; }