#d1204. XOR Inverse

XOR Inverse

XOR Inverse

Problem Description

You are given an array aa of nn non-negative integers. You must choose a non-negative integer xx and XOR every aia_i with xx to form a new array bb. You want the number of inversions in bb to be minimized. If multiple xx achieve the minimum, output the smallest xx.

An inversion is a pair (i,j)(i, j) in array bb satisfying 1≤i<j≤n1 \le i < j \le n and bi>bjb_i > b_j.

Input Format

The first line contains a positive integer nn.

The next line contains nn non-negative integers a1,a2,…,ana_1, a_2, \dots, a_n.

Output Format

Output two numbers: the minimum number of inversions in bb, and the smallest xx achieving it.

Sample Input 1

4
0 1 3 2

Sample Output 1

1 0

Sample Input 2

9
10 7 9 10 7 5 5 3 5

Sample Output 2

4 14

Sample Input 3

3
8 10 3

Sample Output 3

0 8

Constraints

1≤n≤3⋅1051 \le n \le 3 \cdot 10^5, 0≤ai≤1090 \le a_i \le 10^9.