#include <bits/stdc++.h>
using namespace std;
const int64_t INF = 2e9;
int64_t v1[40] = {0}, v2[40] = {0};
void dfs(vector<int64_t>& a, int64_t k) {
  if (a.size() == 0 || k == -1) return;
  vector<int64_t> one, zero;
  int64_t o = 0, z = 0;
  for (auto first : a) {
    int64_t v = first & (1 << k);
    if (v)
      o++, v2[k] += z, one.push_back(first);
    else
      z++, v1[k] += o, zero.push_back(first);
  }
  dfs(zero, k - 1);
  dfs(one, k - 1);
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  int64_t n;
  cin >> n;
  vector<int64_t> a(n);
  for (int64_t i = 0; i < n; i++) cin >> a[i];
  for (int64_t i = 0; i < 40; i++) v1[i] = v2[i] = 0;
  dfs(a, 30);
  int64_t first = 0, ans = 0;
  for (int64_t i = 0; i < 31; i++) {
    if (v2[i] < v1[i])
      first ^= (1 << i), ans += v2[i];
    else
      ans += v1[i];
  }
  cout << ans << " " << first << endl;
  return 0;
}
