human
Give me a code to sum of Bitwise And of all pairs in a given array and the other steps required given the following:
Sum of Bitwise And of all pairs in a given array | Returns value of " arr [ 0 ] ▁ & ▁ arr [ 1 ] ▁ + ▁ arr [ 0 ] ▁ & ▁ arr [ 2 ] ▁ + ▁ . . . ▁ arr [ i ] ▁ & ▁ arr [ j ] ▁ + ▁ . . . . . ▁ arr [ n - 2 ] ▁ & ▁ arr [ n - 1 ] ".
Traverse over all bits.
Count number of elements with i 'th bit set  Initialize the count.
There are k set bits , means k ( k - 1 ) / 2 pairs . Every pair adds 2 ^ i to the answer . Therefore , we add "2 ^ i ▁ * ▁ [ k * ( k - 1 ) / 2 ] " to the answer ..
Driver program to test above function"
How can the above be solved in Python?
assistant
#Here is code to sum of Bitwise And of all pairs in a given array and the other steps required.
 def pairAndSum ( arr , n ) :
	for i in range ( 0 , 32 ) :
		k = 0
		for j in range ( 0 , n ) :
			if ( ( arr [ j ] & ( 1 << i ) ) ) :
				k = k + 1
		ans = ans + ( 1 << i ) * ( k * ( k - 1 ) // 2 )
	return ans
arr = [ 5 , 10 , 15 ]
n = len ( arr )
print ( pairAndSum ( arr , n ) )