#P1416C. XOR Inverse
XOR Inverse
Description
You are given an array consisting of non-negative integers. You have to choose a non-negative integer and form a new array of size according to the following rule: for all from to , ( denotes the operation bitwise XOR).
An inversion in the array is a pair of integers and such that and .
You should choose in such a way that the number of inversions in is minimized. If there are several options for — output the smallest one.
First line contains a single integer () — the number of elements in .
Second line contains space-separated integers , , ..., (), where is the -th element of .
Output two integers: the minimum possible number of inversions in , and the minimum possible value of , which achieves those number of inversions.
Input
First line contains a single integer () — the number of elements in .
Second line contains space-separated integers , , ..., (), where is the -th element of .
Output
Output two integers: the minimum possible number of inversions in , and the minimum possible value of , which achieves those number of inversions.
Note
In the first sample it is optimal to leave the array as it is by choosing .
In the second sample the selection of results in : . It has inversions:
- , ;
- , ;
- , ;
- , .
In the third sample the selection of results in : . It has no inversions.