#include <bits/stdc++.h>
using namespace std;
constexpr int INF = numeric_limits<int>::max() >> 1;
int a[300005], n;
long long f[30][2];
void dfs(int bit, vector<int> x) {
  if (bit == -1 || x.size() == 0) return;
  int g[2] = {0, 0};
  vector<vector<int>> temp(2);
  for (int i : x) {
    int u = (a[i] >> bit & 1);
    f[bit][u] += g[u ^ 1];
    g[u]++;
    temp[u].push_back(i);
  }
  dfs(bit - 1, temp[0]);
  dfs(bit - 1, temp[1]);
}
void solution() {
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  vector<int> temp;
  for (int i = 1; i <= n; i++) temp.push_back(i);
  dfs(30, temp);
  int x = 0;
  long long ans = 0;
  for (int bit = 0; bit < 30; bit++) {
    if (f[bit][0] > f[bit][1]) {
      ans += f[bit][1];
      x ^= (1 << bit);
    } else
      ans += f[bit][0];
  }
  cout << ans << " " << x;
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int tc = 1;
  while (tc--) {
    solution();
    cout << '\n';
  }
}
