human
Write me a code to make all elements of an array equal with the given operation and the other steps required given the following:
Make all elements of an array equal with the given operation | Function that returns true if all the elements of the array can be made equal with the given operation.
To store the sum of the array elements and the maximum element from the array.
Driver code"
Solution in Python:
assistant
#Here is code to make all elements of an array equal with the given operation and the other steps required.
 def isPossible ( n , k , arr ) :
	sum = arr [ 0 ]
	maxVal = arr [ 0 ] ;
	for i in range ( 1 , n ) :
		sum += arr [ i ]
		maxVal = max ( maxVal , arr [ i ] )
	if ( int ( maxVal ) > int ( ( sum + k ) / n ) ) :
		return False
	return True
if __name__ == ' _ _ main _ _ ' :
	k = 8
	arr = [ 1 , 2 , 3 , 4 ]
	n = len ( arr )
	if ( isPossible ( n , k , arr ) ) :
		print ( " Yes " )
	else :
		print ( " No " )