#include <bits/stdc++.h>
using namespace std;
vector<vector<long long>> dp;
void fun(vector<long long> &a, long long bit) {
  if (!a.size() || bit < 0) return;
  long long dp0 = 0, dp1 = 0, z = 0, o = 0;
  vector<long long> l, r;
  for (long long x : a) {
    if (x & (1 << bit)) {
      o++;
      dp1 += z;
      r.push_back(x);
    } else {
      z++;
      dp0 += o;
      l.push_back(x);
    }
  }
  dp[bit][0] += dp0;
  dp[bit][1] += dp1;
  fun(l, bit - 1);
  fun(r, bit - 1);
}
signed main() {
  long long n;
  cin >> n;
  vector<long long> a(n);
  for (long long i = 0; i < n; ++i) cin >> a[i];
  dp.resize(32);
  for (long long i = 0; i < 32; ++i) {
    dp[i].push_back(0);
    dp[i].push_back(0);
  }
  fun(a, 30);
  for (long long i = 0; i < 32; ++i) {
    cerr << dp[i][0] << " " << dp[i][1] << endl;
  }
  long long ans = 0, val = 0;
  for (long long i = 0; i < 32; ++i) {
    if (dp[i][0] <= dp[i][1])
      ans += dp[i][0];
    else {
      ans += dp[i][1];
      val |= (1 << i);
    }
  }
  cout << ans << " " << val;
  return 0;
}
