You are given an array of n elements . You have to find a number which has the highest frequency (i.e, which has occurred most number of times ). If there are more than 1 numbers which has the same number of frequency and their frequency is highest , you have to select the number which is greater among them .
Now , the main challenge is to convert the number into its equivalent binary number , flip the 0's into 1's and 1's into 0's , and then again change it back to decimal and Print it .
Input Format:
First line contain a integer N
Second line contains N different integers
Output Format
Print the required answer
Constraints:
1<=N<=1000
1<=A[i]<=10000
Note : The Time Limit for Each Input is 0.12 seconds .
Input
The First Line contains the total number of elements of the array ,in this case n = 5 .
Second line contains the total elements of the array
Output
Output contains the calculated result.
For the Sample Input,
3 and 7 occurred the maximum number of times . But since 7 > 3 , we choose 7 . Then the binary of 7 is 111 . Then we change all the 1's to 0's and vice-versa . so now we have 000 and its decimal equivalent is 0 . Hence 0 is the output.