#include <bits/stdc++.h>
std::mt19937_64 rng(
    std::chrono::steady_clock::now().time_since_epoch().count());
long long int myRand(long long int R) {
  long long int val = rng() % R;
  assert(val >= 0);
  return val;
}
const long double PI = atan(1.0) * 4;
const int32_t INF32 = 2e9 + 7;
const int64_t INF64 = 3e18;
const int32_t LOG = 21;
const int32_t MOD = 1e9 + 7;
using namespace std;
void my_debugger(string second, long long int LINE_NUM) { cerr << '\n'; }
template <typename start, typename... end>
void my_debugger(string second, long long int LINE_NUM, start x, end... y) {
  if (second.back() != ',') {
    second += ',';
    cerr << "LINE(" << LINE_NUM << "): ";
  }
  long long int i = second.find(',');
  cerr << second.substr(0, i) << " = " << x;
  second = second.substr(i + 1);
  if (!second.empty()) cerr << ", ";
  my_debugger(second, LINE_NUM, y...);
}
long long int tot[35][2];
void solve(long long int bit, vector<long long int>& pos,
           vector<long long int>& a) {
  if (bit < 0) return;
  long long int case1_val = 0, case2_val = 0;
  {
    long long int cnt = 0;
    for (auto& it : pos) {
      if ((1 << bit) & a[it])
        cnt++;
      else
        case1_val += cnt;
    }
  }
  {
    for (auto& it : pos) a[it] ^= (1 << bit);
    long long int cnt = 0;
    for (auto& it : pos) {
      if ((1 << bit) & a[it])
        cnt++;
      else
        case2_val += cnt;
    }
  }
  for (auto& it : pos) a[it] ^= (1 << bit);
  vector<long long int> pos1, pos2;
  for (auto& it : pos) {
    if ((1 << bit) & a[it])
      pos1.push_back(it);
    else
      pos2.push_back(it);
  }
  tot[bit][0] += case1_val;
  tot[bit][1] += case2_val;
  if (!pos1.empty()) solve(bit - 1, pos1, a);
  if (!pos2.empty()) solve(bit - 1, pos2, a);
}
int32_t main() {
  ios_base::sync_with_stdio(false), cin.tie(nullptr);
  long long int tests = 1;
  for (long long int ii = 0; ii < (long long int)tests; ii++) {
    long long int n;
    cin >> n;
    vector<long long int> a(n + 1, 0);
    vector<long long int> high(n + 1, 0);
    for (long long int i = 1; i < (long long int)n + 1; i++) cin >> a[i];
    vector<long long int> pos;
    for (long long int i = 1; i < (long long int)n + 1; i++) pos.push_back(i);
    solve(30, pos, a);
    long long int inversions = 0, x = 0;
    for (long long int bit = (long long int)30; bit >= 0; bit--) {
      inversions += min(tot[bit][0], tot[bit][1]);
      if (tot[bit][0] > tot[bit][1]) x ^= (1 << bit);
    }
    cout << inversions << " " << x << '\n';
  }
  return 0;
}
