Kumara S.

asked • 07/25/22

arrays sum AND in data stuctures

Antonio got an array A for his christmas present. Array A consists of N positive integers.


He wants to give a pair of integers from this array to his girlfriend Teena.


Teena likes a pair of integers (a,b) if and only if (a+b)/2 equals the bitwise AND of a and b. In other words Teena likes an integer pair (a,b) if and only if (a+b)/2 = Bitwise AND(a,b) holds.


Now Antonio wants to find the number of pairs he can gift to Teena such that she likes it. Note that an element of the array can be a part of atmost one pair.


As Antonio is weak in arrays he asked you for help. Help Him !




Input Format




First line contains a single integer denoting N.

Next line contains N space separated integers denoting the elements of array A.



Output Format




Print the number of pairs Antonio can gift to Teena such that she likes it.



Constraints




1<=N<=105

1<=Ai<=109

1 Expert Answer

By:

Calvin D. answered • 08/02/22

Tutor
5 (233)

Data Scientist

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.