#include <bits/stdc++.h>
using namespace std;
mt19937 rnd(time(0));
const double eps = 1e-10;
const long long inf = 0x3f3f3f3f3f3f3f3fLL;
const long long N = 5e5 + 5;
const long long MOD = 1e9 + 7;
long long pw(long long b, long long p) {
  b %= MOD;
  long long res = 1;
  while (p > 0) {
    if (p & 1) res = res * b % MOD;
    b = b * b % MOD;
    p >>= 1;
  }
  return res;
}
const long long mxBit = 30;
vector<long long> a;
long long ans, x, dp[mxBit][2];
void go(long long bit, vector<long long> &v) {
  if (bit < 0 || v.empty()) return;
  long long cnt01 = 0, cnt10 = 0;
  long long res01 = 0, res10 = 0;
  vector<long long> a01, a10;
  for (long long i = 0; i < v.size(); i++) {
    if (v[i] >> bit & 1) {
      res01 += cnt01;
      cnt10++;
      a01.push_back(v[i]);
    } else {
      res10 += cnt10;
      cnt01++;
      a10.push_back(v[i]);
    }
  }
  dp[bit][0] += res10;
  dp[bit][1] += res01;
  go(bit - 1, a10);
  go(bit - 1, a01);
}
int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long n;
  cin >> n;
  a.assign(n, 0);
  for (auto &i : a) {
    cin >> i;
  }
  go(mxBit, a);
  for (long long i = 0; i < mxBit; i++) {
    ans += min(dp[i][0], dp[i][1]);
    if (dp[i][1] < dp[i][0]) {
      x |= (1LL << i);
    }
  }
  cout << ans << ' ' << x << '\n';
  return 0;
}
