#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
const double PI = acos(-1.0);
const double epsilon = PI / 180.0;
long long powmod(long long a, long long b) {
  long long res = 1;
  a %= mod;
  assert(b >= 0);
  for (; b; b >>= 1) {
    if (b & 1) res = res * a % mod;
    a = a * a % mod;
  }
  return res;
}
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
const int N = 3e5 + 10, M = 1e6 + 10;
int son[N * 30][2], idx;
vector<int> ed[N * 30];
void insert(int x, int m, int id) {
  int p = 0;
  for (int i = m - 1; i >= 0; i--) {
    int u = x >> i & 1;
    if (!son[p][u]) son[p][u] = ++idx;
    p = son[p][u];
  }
  ed[p].push_back(id);
}
int n, len;
int a[N];
long long cnt[40][2];
string s;
vector<int> dfs(int x, int p) {
  if (ed[p].size()) {
    return ed[p];
  }
  vector<int> v[2];
  for (int i = 0; i < 2; i++) {
    if (son[p][i]) v[i] = dfs(x + 1, son[p][i]);
  }
  if (v[0].size() == 0) return v[1];
  if (v[1].size() == 0) return v[0];
  int i = 0, j = 0;
  vector<int> res;
  long long sum0 = 0, sum1 = 0;
  while (i < v[0].size() && j < v[1].size()) {
    if (v[0][i] < v[1][j]) {
      sum0 += v[1].size() - j;
      res.push_back(v[0][i++]);
    } else if (v[0][i] > v[1][j]) {
      sum1 += v[0].size() - i;
      res.push_back(v[1][j++]);
    } else {
      res.push_back(v[0][i++]);
    }
  }
  cnt[x][0] += sum0;
  cnt[x][1] += sum1;
  while (i < v[0].size()) res.push_back(v[0][i++]);
  while (j < v[1].size()) res.push_back(v[1][j++]);
  return res;
}
int tr[N];
int lowbit(int x) { return x & -x; }
void add(int x, int d) {
  for (int i = x; i <= n; i += lowbit(i)) tr[i] += d;
}
int sum(int x) {
  int res = 0;
  for (int i = x; i; i -= lowbit(i)) res += tr[i];
  return res;
}
int main() {
  cin >> n;
  for (int i = 1; i < n + 1; i++) {
    int t;
    cin >> t;
    a[i] = t;
    s = "";
    while (t) {
      s += t & 1 + '0';
      t >>= 1;
    }
    len = max(len, ((int)(s).size()));
  }
  for (int i = 1; i < n + 1; i++) insert(a[i], len, i);
  dfs(0, 0);
  s = "";
  for (int i = 0; i < len; i++) {
    if (cnt[i][0] < cnt[i][1])
      s += '1';
    else if (cnt[i][1] < cnt[i][0])
      s += '0';
    else
      s += '0';
  }
  int ans = 0;
  for (int i = 0; i < len; i++) {
    ans *= 2;
    ans += s[i] - '0';
  }
  long long num = 0;
  vector<int> tt;
  tt.push_back(-0x3f3f3f3f);
  for (int i = 1; i < n + 1; i++) {
    a[i] = a[i] ^ ans;
    tt.push_back(a[i]);
  }
  cout << "\n";
  sort((tt).begin(), (tt).end());
  tt.erase(unique((tt).begin(), (tt).end()), tt.end());
  for (int i = n + 1 - 1; i >= 1; i--) {
    int id = lower_bound((tt).begin(), (tt).end(), a[i]) - tt.begin();
    if (id > 1) num += sum(id - 1);
    add(id, 1);
  }
  cout << num << " " << ans;
  return 0;
}

### Prompt

Please formulate a CPP solution to the following problem:

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.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
const double PI = acos(-1.0);
const double epsilon = PI / 180.0;
long long powmod(long long a, long long b) {
  long long res = 1;
  a %= mod;
  assert(b >= 0);
  for (; b; b >>= 1) {
    if (b & 1) res = res * a % mod;
    a = a * a % mod;
  }
  return res;
}
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
const int N = 3e5 + 10, M = 1e6 + 10;
int son[N * 30][2], idx;
vector<int> ed[N * 30];
void insert(int x, int m, int id) {
  int p = 0;
  for (int i = m - 1; i >= 0; i--) {
    int u = x >> i & 1;
    if (!son[p][u]) son[p][u] = ++idx;
    p = son[p][u];
  }
  ed[p].push_back(id);
}
int n, len;
int a[N];
long long cnt[40][2];
string s;
vector<int> dfs(int x, int p) {
  if (ed[p].size()) {
    return ed[p];
  }
  vector<int> v[2];
  for (int i = 0; i < 2; i++) {
    if (son[p][i]) v[i] = dfs(x + 1, son[p][i]);
  }
  if (v[0].size() == 0) return v[1];
  if (v[1].size() == 0) return v[0];
  int i = 0, j = 0;
  vector<int> res;
  long long sum0 = 0, sum1 = 0;
  while (i < v[0].size() && j < v[1].size()) {
    if (v[0][i] < v[1][j]) {
      sum0 += v[1].size() - j;
      res.push_back(v[0][i++]);
    } else if (v[0][i] > v[1][j]) {
      sum1 += v[0].size() - i;
      res.push_back(v[1][j++]);
    } else {
      res.push_back(v[0][i++]);
    }
  }
  cnt[x][0] += sum0;
  cnt[x][1] += sum1;
  while (i < v[0].size()) res.push_back(v[0][i++]);
  while (j < v[1].size()) res.push_back(v[1][j++]);
  return res;
}
int tr[N];
int lowbit(int x) { return x & -x; }
void add(int x, int d) {
  for (int i = x; i <= n; i += lowbit(i)) tr[i] += d;
}
int sum(int x) {
  int res = 0;
  for (int i = x; i; i -= lowbit(i)) res += tr[i];
  return res;
}
int main() {
  cin >> n;
  for (int i = 1; i < n + 1; i++) {
    int t;
    cin >> t;
    a[i] = t;
    s = "";
    while (t) {
      s += t & 1 + '0';
      t >>= 1;
    }
    len = max(len, ((int)(s).size()));
  }
  for (int i = 1; i < n + 1; i++) insert(a[i], len, i);
  dfs(0, 0);
  s = "";
  for (int i = 0; i < len; i++) {
    if (cnt[i][0] < cnt[i][1])
      s += '1';
    else if (cnt[i][1] < cnt[i][0])
      s += '0';
    else
      s += '0';
  }
  int ans = 0;
  for (int i = 0; i < len; i++) {
    ans *= 2;
    ans += s[i] - '0';
  }
  long long num = 0;
  vector<int> tt;
  tt.push_back(-0x3f3f3f3f);
  for (int i = 1; i < n + 1; i++) {
    a[i] = a[i] ^ ans;
    tt.push_back(a[i]);
  }
  cout << "\n";
  sort((tt).begin(), (tt).end());
  tt.erase(unique((tt).begin(), (tt).end()), tt.end());
  for (int i = n + 1 - 1; i >= 1; i--) {
    int id = lower_bound((tt).begin(), (tt).end(), a[i]) - tt.begin();
    if (id > 1) num += sum(id - 1);
    add(id, 1);
  }
  cout << num << " " << ans;
  return 0;
}

```