#include <bits/stdc++.h>
using namespace std;
const int sz = 4e5;
long long a[sz], n;
long long curinv[32], flipinv[32];
void foo(vector<int> v, int b) {
  if (b < 0 || v.empty()) return;
  vector<int> zvec, ovec;
  int z = 0, o = 0;
  for (int k : v) {
    if ((k >> b) & 1) {
      o++;
      flipinv[b] += z;
      ovec.push_back(k);
    } else {
      z++;
      curinv[b] += o;
      zvec.push_back(k);
    }
  }
  foo(zvec, b - 1);
  foo(ovec, b - 1);
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  vector<int> v;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    v.push_back(a[i]);
  }
  foo(v, 31);
  long long mynum = 0, totinv = 0;
  for (int b = 0; b < 32; b++) {
    if (curinv[b] <= flipinv[b])
      totinv += curinv[b];
    else {
      totinv += flipinv[b];
      mynum |= (1 << b);
    }
  }
  cout << totinv << " " << mynum << endl;
  return 0;
}
