Maximize the sum of arr [ i ] * i | C # program to find the maximum value of i * arr [ i ] ; Sort the array ; Finding the sum of arr [ i ] * i ; Driver code
using System ; class GFG { static int maxSum ( int [ ] arr , int n ) { Array . Sort ( arr ) ; int sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) sum += ( arr [ i ] * i ) ; return sum ; } static public void Main ( ) { int [ ] arr = { 3 , 5 , 6 , 1 } ; int n = arr . Length ; Console . WriteLine ( maxSum ( arr , n ) ) ; } }