human
Maximize the sum of sum of the Array by removing end elements | Function to find the maximum sum of sum.
Compute the sum of whole array.
Traverse and remove the minimum value from an end to maximum the sum value.
If the left end element is smaller than right end.
Remove the left end element.
If the right end element is smaller than left end.
Remove the right end element.
Add the remaining element sum in the result.
Return the maximum sum of sum.
Driver code"
Solution in Python:
 Write me a code to maximize the sum of sum of the Array by removing end elements and the other steps required?
assistant
#Here is code to maximize the sum of sum of the Array by removing end elements and the other steps required.
 def maxRemainingSum ( arr , n ) :
	sum = 0
	for i in range ( n ) :
		sum += arr [ i ]
	i = 0
	j = n - 1
	result = 0
	while ( i < j ) :
		if ( arr [ i ] < arr [ j ] ) :
			sum -= arr [ i ]
			i += 1
		else :
			sum -= arr [ j ]
			j -= 1
		result += sum ;
	return result
arr = [ 3 , 1 , 7 , 2 , 1 ]
N = len ( arr )
print ( maxRemainingSum ( arr , N ) )