#include <bits/stdc++.h>
using namespace std;
vector<vector<long long> > vec[2];
vector<long long> x, y;
int main() {
  long long n, bit = 0, ans1 = 0, ans2 = 0, a, b;
  cin >> n;
  for (long long i = 1; i <= n; i++) {
    scanf("%I64d", &a);
    x.push_back(a);
  }
  vec[bit].push_back(x);
  for (long long i = 32; i >= 0; i--) {
    long long bb = (1ll << i), curAns = 0, curAns2 = 0;
    for (auto v : vec[bit]) {
      long long cnt = 0, cnt2 = 0;
      x.clear();
      y.clear();
      for (auto cur : v)
        if (cur & bb) {
          x.push_back(cur);
          cnt++;
          curAns2 += cnt2;
        } else {
          curAns += cnt;
          cnt2++;
          y.push_back(cur);
        }
      if (!x.empty()) vec[bit ^ 1].push_back(x);
      if (!y.empty()) vec[bit ^ 1].push_back(y);
    }
    ans1 += min(curAns, curAns2);
    if (curAns2 < curAns) {
      ans2 += bb;
    }
    vec[bit].clear();
    bit ^= 1;
  }
  cout << ans1 << " " << ans2 << endl;
  return 0;
}
