Sum of minimum element of all subarrays of a sorted array | Function to find the sum of minimum of all subarrays ; Driver code
function findMinSum ( arr , n ) { var sum = 0 ; for ( var i = 0 ; i < n ; i ++ ) sum += arr [ i ] * ( n - i ) ; return sum ; } var arr = [ 3 , 5 , 7 , 8 ] ; var n = arr . length ; document . write ( findMinSum ( arr , n ) ) ;