human
Count pairs from an array having product of their sum and difference equal to 1 | Function to count the desired number of pairs.
Initialize oneCount.
Initialize the desiredPair.
Traverse the given array.
If 1 is encountered.
If 0 is encountered.
Update count of pairs.
Return the final count.
Driver Code.
Given array arr [ ].
Function call"
Solution in Python:

Give me a code to count pairs from an array having product of their sum and difference equal to 1 and the other steps required?
assistant
#Here is code to count pairs from an array having product of their sum and difference equal to 1 and the other steps required.
 def countPairs ( arr , n ) :
	oneCount = 0
	desiredPair = 0
	for i in range ( n ) :
		if ( arr [ i ] == 1 ) :
			oneCount += 1
		if ( arr [ i ] == 0 ) :
			desiredPair += oneCount
	return desiredPair
if __name__ == ' _ _ main _ _ ' :
	arr = [ 3 , 1 , 1 , 0 ]
	N = len ( arr )
	print ( countPairs ( arr , N ) )