human
Minimum operations to make Array equal by repeatedly adding K from an element and subtracting K from other | Function to find the minimum number of operations to make all the elements of the array equal.
Store the sum of the array arr [ ].
Traverse through the array.
If it is not possible to make all array element equal.
Store the minimum number of operations needed.
Traverse through the array.
Finally , print the minimum number operation to make array elements equal.
Driver Code.
Given Input.
Function Call"
Solution in Python:

What is a code to minimum operations to make Array equal by repeatedly adding K from an element and subtracting K from other and the other steps required?
assistant
#Here is code to minimum operations to make Array equal by repeatedly adding K from an element and subtracting K from other and the other steps required.
 def miniOperToMakeAllEleEqual ( arr , n , k ) :
	sum = 0
	for i in range ( n ) :
		sum += arr [ i ]
	if ( sum % n ) :
		print ( - 1 )
		return
	valueAfterDivision = sum // n
	count = 0
	for i in range ( n ) :
		if ( abs ( valueAfterDivision - arr [ i ] ) % k != 0 ) :
			print ( - 1 )
			return
		count += abs ( valueAfterDivision - arr [ i ] ) // k
	print ( count // 2 )
if __name__ == ' _ _ main _ _ ' :
	n = 3
	k = 3
	arr = [ 5 , 8 , 11 ]
	miniOperToMakeAllEleEqual ( arr , n , k )