#include <bits/stdc++.h>
using namespace std;
template <typename C>
auto test(C* x) -> decltype(cerr << *x, 0LL);
template <typename C>
char test(...);
template <typename C>
struct itr {
  C begin, end;
};
template <typename C>
itr<C> get_range(C b, C e) {
  return itr<C>{b, e};
};
struct debug {
  template <typename T>
  debug& operator<<(const T&) {
    return *this;
  }
};
string _ARR_(int* arr, int sz) {
  string ret = "{ " + to_string(arr[0]);
  for (int i = 1; i < sz; i++) ret += " , " + to_string(arr[i]);
  ret += " }";
  return ret;
}
const int INF = 1e9 + 7;
const int MxN = 3e5 + 100;
int i, n, a[MxN];
long long ans = 0, ansx = 0;
vector<vector<int>> groups, ngroups;
void solve(unsigned long long bit) {
  long long swapcur = 0, cur = 0;
  for (auto v : groups) {
    vector<int> grp1, grp2;
    long long ones = 0;
    for (int i : v) {
      if (a[i] & bit) {
        ones++;
        grp1.push_back(i);
      } else {
        cur += ones;
        grp2.push_back(i);
      }
    }
    if (!grp1.empty()) ngroups.push_back(grp1);
    if (!grp2.empty()) ngroups.push_back(grp2);
  }
  for (auto v : groups) {
    long long ones = 0;
    for (int i : v) {
      if (a[i] & bit)
        swapcur += ones;
      else
        ones++;
    }
  }
  if (swapcur < cur) {
    ans += swapcur;
    ansx |= bit;
  } else {
    ans += cur;
  }
  groups = ngroups;
  ngroups.clear();
  return;
}
int main(void) {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  vector<int> v;
  for (i = 0; i < n; i++) {
    v.push_back(i);
    cin >> a[i];
  }
  groups.push_back(v);
  for (int i = 31; i >= 0; i--) {
    solve((1 << i));
  }
  cout << ans << ' ' << ansx << '\n';
  return 0;
}
