You are given an array a consisting of n non-negative integers. You have to choose a non-negative integer x and form a new array b of size n according to the following rule: for all i from 1 to n, b_i = a_i ⊕ x (⊕ denotes the operation [bitwise XOR](https://en.wikipedia.org/wiki/Bitwise_operation#XOR)).

An inversion in the b array is a pair of integers i and j such that 1 ≤ i < j ≤ n and b_i > b_j.

You should choose x in such a way that the number of inversions in b is minimized. If there are several options for x — output the smallest one.

Input

First line contains a single integer n (1 ≤ n ≤ 3 ⋅ 10^5) — the number of elements in a.

Second line contains n space-separated integers a_1, a_2, ..., a_n (0 ≤ a_i ≤ 10^9), where a_i is the i-th element of a.

Output

Output two integers: the minimum possible number of inversions in b, and the minimum possible value of x, which achieves those number of inversions.

Examples

Input


4
0 1 3 2


Output


1 0


Input


9
10 7 9 10 7 5 5 3 5


Output


4 14


Input


3
8 10 3


Output


0 8

Note

In the first sample it is optimal to leave the array as it is by choosing x = 0.

In the second sample the selection of x = 14 results in b: [4, 9, 7, 4, 9, 11, 11, 13, 11]. It has 4 inversions:

  * i = 2, j = 3; 
  * i = 2, j = 4; 
  * i = 3, j = 4; 
  * i = 8, j = 9. 



In the third sample the selection of x = 8 results in b: [0, 2, 11]. It has no inversions.
#include <bits/stdc++.h>
using namespace std;
const double EPS = 1e-5;
const double PI = acos(-1);
const long long mod = 1e4 + 7;
const int INF = 0x3f3f3f3f;
inline int sgn(double a) { return a < -EPS ? -1 : a > EPS; }
inline int cmp(double a, double b) { return sgn(a - b); }
inline long long gcd(long long x, long long y) {
  if (y == 0) return x;
  return gcd(y, x % y);
}
inline long long ksm(long long a, long long x) {
  long long ret = 1;
  while (x) {
    if (x & 1) ret = (ret * ret) % mod;
    a = (a * a) % mod;
    x >>= 1;
  }
  return ret;
}
const int MAXN = 3e5 + 10;
const int N = 1e4 + 10;
int n, m;
int fa[MAXN];
int a[MAXN], b[MAXN];
long long merge_sort(int l, int r) {
  if (l >= r) return 0;
  int mid = (l + r) >> 1;
  long long ret = merge_sort(l, mid);
  ret += merge_sort(mid + 1, r);
  int i = l, j = mid + 1;
  int num = l;
  while (i <= mid && j <= r) {
    if (a[i] <= a[j])
      b[num++] = a[i++];
    else {
      b[num++] = a[j++];
      ret += mid - i + 1;
    }
  }
  while (i <= mid) b[num++] = a[i++];
  while (j <= r) b[num++] = a[j++];
  for (i = l; i <= r; i++) a[i] = b[i];
  return ret;
}
void solve() {
  for (int j = 1; j <= n; j++) a[j] = fa[j];
  long long now = merge_sort(1, n);
  int ans = 0;
  for (int i = 30; i >= 0; i--) {
    int base = (1 << i);
    for (int j = 1; j <= n; j++) a[j] = fa[j] ^ base;
    long long tmp = merge_sort(1, n);
    if (tmp < now) {
      for (int j = 1; j <= n; j++) fa[j] = fa[j] ^ base;
      ans += base;
      now = tmp;
    }
  }
  for (int j = 1; j <= n; j++) a[j] = fa[j];
  printf("%lld %d\n", merge_sort(1, n), ans);
}
void init() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", fa + i);
}
signed main() {
  int T = 1;
  while (T--) {
    init();
    solve();
  }
  return 0;
}
