#include <bits/stdc++.h>
using namespace std;
int n, tri[8000010][2], tot;
long long f[31][2];
vector<int> son[8000010];
inline void insert(int x, int id) {
  int rt = 0;
  for (int i = 29; i >= 0; --i) {
    int v = (x >> i) & 1;
    if (!tri[rt][v]) tri[rt][v] = ++tot;
    rt = tri[rt][v];
    son[rt].push_back(id);
  }
}
void dp(int rt, int bit) {
  int l = tri[rt][0], r = tri[rt][1];
  if (l) dp(l, bit - 1);
  if (r) dp(r, bit - 1);
  if (!l || !r) return;
  long long cnt = 0, ptr = 0;
  for (int i = 0; i < son[l].size(); ++i) {
    while (ptr < son[r].size() && son[r][ptr] < son[l][i]) ++ptr;
    cnt += ptr;
  }
  f[bit][0] += cnt, f[bit][1] += (long long)son[l].size() * son[r].size() - cnt;
}
signed main() {
  cin >> n;
  for (int i = 1, a; i <= n; ++i) {
    cin >> a;
    insert(a, i);
  }
  dp(0, 29);
  long long cnt = 0, ans = 0;
  for (int i = 0; i <= 29; ++i) {
    cnt += min(f[i][1], f[i][0]);
    if (f[i][1] < f[i][0]) ans |= (1 << i);
  }
  return cout << cnt << ' ' << ans, 0;
}
