human
What is a code to removing a number from array without changing its arithmetic mean and the other steps required given the following:
Removing a number from array without changing its arithmetic mean | Function to remove a number from the array without changing its arithmetic mean.
Find sum of all elements.
If mean is an integer.
Check if mean is present in the array or not.
Driver code"
How can the above be solved in Python?
assistant
#Here is code to removing a number from array without changing its arithmetic mean and the other steps required.
 def FindElement ( a , n ) :
	s = 0
	for i in range ( n ) :
		s = s + a [ i ]
	if s % n == 0 :
		m = s // n
		for j in range ( n ) :
			if a [ j ] == m :
				return m
	return - 1
if __name__ == " _ _ main _ _ " :
	a = [ 1 , 2 , 3 , 4 , 5 ]
	n = len ( a )
	print ( FindElement ( a , n ) )