AlgoUniversity
  • Go Back
Discussion
XOR AND Inversions :

Author

Shikhar Mehrotra

Difficulty Level : Easy

Submissions : 163

Asked In : Hexaware

Marks :10

: 5 | : 0

You are given an integer array $$$A$$$ of size $$$N$$$. Your task is to count number of XOR AND inversion iff if it satisfies the following conditon.

$$$1\le i < j \le N$$$

$$$A[i] $$$&$$$ A[j] ≥ $$$ $$$A[i] $$$^$$$ A[j]$$$

Input

First line contains an integer $$$1\le N\le 10^{5}$$$.

Second line contains $$$N$$$ space separated integers denoting array elements $$$1\le A[i] \le 10^{5}$$$ where $$$(1\le i \le N)$$$

Output

Print count of XOR AND inversions as described above.

Examples

Input
5
7 12 16 10 6
Output
2
Input
6
2 4 32 8 16 64
Output
0

Note

Here $$$&$$$ denotes bitwise AND and $$$^$$$ denotes bitwise XOR.

In first test case there are only 2 pairs that satisfy both the conditions those are.

$$$1>$$$ $$$(1,5)$$$ its respective element are $$$(7,6)$$$, $$$(7$$$&$$$6)=6$$$ and $$$(7$$$^$$$6)=1$$$ Here $$$(7&6)≥(7^6)$$$

$$$2>$$$ $$$(2,4)$$$ its respective element are $$$(12,10)$$$, $$$(12$$$&$$$10)=8$$$ and $$$(12$$$^$$$10)=6$$$ Here $$$(12&10)≥(12^10)$$$

You need to login to view your submissions.

You need to login to view all submissions.

Loading...

Result : Executed

Loading...

Feel something is wrong with the test cases?

Result : Accepted

Test Cases :

You need to Log In
We're glad that you want to attempt this problem!

But to Run or Submit the Problem, you need to Log In.

Continue to Log In
Challenge Submitted!

Your challenge has been submitted successfully.

You will get a response soon via WhatsApp or Email.

Challenge
Facing issue while trying to solve the problem! Don't worry, we got you covered!

Do let us know your issue.

Looks good!
Please enter your issue / feedback.

How do we get in touch with you?
Looks good!
Please enter your phone no.
Looks good!
Please enter your email address.