#include <bits/stdc++.h>
using namespace std;
const int MaxN = 3e5 + 5;
long long _10[MaxN], _01[MaxN];
vector<long long> vv;
void dfs(vector<long long> v, int d) {
  if (v.empty()) return;
  if (d < 0) return;
  long long base = 1LL << d;
  vector<long long> l, r;
  long long _0 = 0, _1 = 0;
  for (int i = 0; i < v.size(); i++) {
    if ((v[i] & base) == 0) {
      _10[d] += _1;
      ++_0;
      l.push_back(v[i]);
    } else {
      _01[d] += _0;
      ++_1;
      r.push_back(v[i]);
    }
  }
  dfs(l, d - 1);
  dfs(r, d - 1);
}
void solve() {
  int n;
  cin >> n;
  vv.clear();
  long long tp;
  for (int i = 0; i < 60; i++) _01[i] = _10[i] = 0;
  for (int i = 0; i < n; i++) {
    cin >> tp;
    vv.push_back(tp);
  }
  dfs(vv, 60);
  long long cnt = 0;
  long long x = 0;
  for (int i = 60; i >= 0; i--) {
    if (_01[i] < _10[i]) {
      cnt += _01[i];
      x |= (1 << i);
    } else {
      cnt += _10[i];
    }
  }
  cout << cnt << " " << x << "\n";
}
int main() {
  ios::sync_with_stdio(0);
  solve();
  return 0;
}
