human
Sum of product of all pairs of a Binary Array | Function to print the sum of product of all pairs of the given array.
Stores count of one in the given array.
Stores the size of the given array.
If current element is 1.
Increase count.
Return the sum of product of all pairs.
Driver Code"
How can the above be solved in Python?
 ... What is a code to sum of product of all pairs of a Binary Array and the other steps required?
assistant
#Here is code to sum of product of all pairs of a Binary Array and the other steps required.
 def productSum ( arr ) :
	cntOne = 0
	N = len ( arr )
	for i in range ( N ) :
		if ( arr [ i ] == 1 ) :
			cntOne += 1
	return cntOne * ( cntOne - 1 ) // 2
arr = [ 0 , 1 , 1 , 0 , 1 ]
print ( productSum ( arr ) )