human
Minimize the sum of the array according the given condition | Function to return the minimum sum.
sort the array to find the minimum element.
finding the number to divide.
Checking to what instance the sum has decreased.
getting the max difference.
Driver Code"
How can the above be solved in Python?
assistant
#Here is code to minimize the sum of the array according the given condition and the other steps required.
 def findMin ( arr , n ) :
	sum = 0
	for i in range ( 0 , n ) :
		sum = sum + arr [ i ]
	arr . sort ( )
	min = arr [ 0 ]
	max = 0
	for i in range ( n - 1 , 0 , - 1 ) :
		num = arr [ i ]
		total = num + min
		for j in range ( 2 , num + 1 ) :
			if ( num % j == 0 ) :
				d = j
				now = ( num // d ) + ( min * d )
				reduce = total - now
				if ( reduce > max ) :
					max = reduce
	print ( sum - max )
arr = [ 1 , 2 , 3 , 4 , 5 ]
n = len ( arr )
findMin ( arr , n )