#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using pi = pair<int, int>;
using pll = pair<ll, ll>;
template <class T>
using vv = vector<vector<T>>;
template <class T>
inline bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
inline bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
const int INF = 1002003004;
const ll LINF = 1002003004005006007ll;
struct preprocess {
  preprocess() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} ____;
template <typename T>
struct BinaryIndexedTree {
  int sz;
  vector<T> data;
  BinaryIndexedTree(int sz) : sz(sz), data(sz + 1) {}
  T sum(int k) {
    T res = 0;
    for (k++; k > 0; k -= k & -k) res += data[k];
    return res;
  }
  T sum(int l, int r) { return sum(r - 1) - sum(l - 1); }
  void add(int k, T x) {
    for (k++; k <= sz; k += k & -k) data[k] += x;
  }
  int lower_bound(T w) {
    if (w <= 0) return 0;
    int x = 0;
    int k = 1;
    while ((k << 1) <= sz) k <<= 1;
    for (; k > 0; k >>= 1) {
      if (x + k <= sz && data[x + k] < w) {
        w -= data[x + k];
        x += k;
      }
    }
    return x;
  }
};
int main() {
  int n;
  cin >> n;
  vll a(n);
  for (int i = 0; i < (int)(n); i++) cin >> a[i];
  vv<int> sets;
  vector<int> init(n);
  iota((init).begin(), (init).end(), 0);
  sets.emplace_back(init);
  ll ans = 0;
  ll inv = 0;
  for (int bi = (int)(34) - 1; bi >= 0; bi--) {
    ll val = 1ll << bi;
    vv<int> nxt;
    ll now = 0;
    ll nowinv = 0;
    for (int i = 0; i < (int)(sets.size()); i++) {
      vi &v = sets[i];
      vi b;
      for (int j = 0; j < (int)(v.size()); j++) {
        if (a[v[j]] & val) {
          b.emplace_back(1);
        } else {
          b.emplace_back(0);
        }
      }
      ll ones = 0;
      for (int j = 0; j < (int)(b.size()); j++) {
        if (b[j]) {
          ones++;
        } else {
          now += ones;
        }
      }
      ones = 0;
      for (int j = 0; j < (int)(b.size()); j++) {
        if (!b[j]) {
          ones++;
        } else {
          nowinv += ones;
        }
      }
      vi nxt1, nxt2;
      for (int j = 0; j < (int)(b.size()); j++) {
        if (b[j]) {
          nxt1.emplace_back(v[j]);
        } else {
          nxt2.emplace_back(v[j]);
        }
      }
      if (!nxt1.empty()) nxt.emplace_back(nxt1);
      if (!nxt2.empty()) nxt.emplace_back(nxt2);
    }
    if (now > nowinv) {
      ans |= val;
    }
    inv += min(now, nowinv);
    sets = nxt;
  }
  cout << inv << ' ' << ans << '\n';
}

### Prompt

Your challenge is to write 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;
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using pi = pair<int, int>;
using pll = pair<ll, ll>;
template <class T>
using vv = vector<vector<T>>;
template <class T>
inline bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
inline bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
const int INF = 1002003004;
const ll LINF = 1002003004005006007ll;
struct preprocess {
  preprocess() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} ____;
template <typename T>
struct BinaryIndexedTree {
  int sz;
  vector<T> data;
  BinaryIndexedTree(int sz) : sz(sz), data(sz + 1) {}
  T sum(int k) {
    T res = 0;
    for (k++; k > 0; k -= k & -k) res += data[k];
    return res;
  }
  T sum(int l, int r) { return sum(r - 1) - sum(l - 1); }
  void add(int k, T x) {
    for (k++; k <= sz; k += k & -k) data[k] += x;
  }
  int lower_bound(T w) {
    if (w <= 0) return 0;
    int x = 0;
    int k = 1;
    while ((k << 1) <= sz) k <<= 1;
    for (; k > 0; k >>= 1) {
      if (x + k <= sz && data[x + k] < w) {
        w -= data[x + k];
        x += k;
      }
    }
    return x;
  }
};
int main() {
  int n;
  cin >> n;
  vll a(n);
  for (int i = 0; i < (int)(n); i++) cin >> a[i];
  vv<int> sets;
  vector<int> init(n);
  iota((init).begin(), (init).end(), 0);
  sets.emplace_back(init);
  ll ans = 0;
  ll inv = 0;
  for (int bi = (int)(34) - 1; bi >= 0; bi--) {
    ll val = 1ll << bi;
    vv<int> nxt;
    ll now = 0;
    ll nowinv = 0;
    for (int i = 0; i < (int)(sets.size()); i++) {
      vi &v = sets[i];
      vi b;
      for (int j = 0; j < (int)(v.size()); j++) {
        if (a[v[j]] & val) {
          b.emplace_back(1);
        } else {
          b.emplace_back(0);
        }
      }
      ll ones = 0;
      for (int j = 0; j < (int)(b.size()); j++) {
        if (b[j]) {
          ones++;
        } else {
          now += ones;
        }
      }
      ones = 0;
      for (int j = 0; j < (int)(b.size()); j++) {
        if (!b[j]) {
          ones++;
        } else {
          nowinv += ones;
        }
      }
      vi nxt1, nxt2;
      for (int j = 0; j < (int)(b.size()); j++) {
        if (b[j]) {
          nxt1.emplace_back(v[j]);
        } else {
          nxt2.emplace_back(v[j]);
        }
      }
      if (!nxt1.empty()) nxt.emplace_back(nxt1);
      if (!nxt2.empty()) nxt.emplace_back(nxt2);
    }
    if (now > nowinv) {
      ans |= val;
    }
    inv += min(now, nowinv);
    sets = nxt;
  }
  cout << inv << ' ' << ans << '\n';
}

```