#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9 + 7;
long long inv[30][2];
void rec(vector<long long> &a, int bit) {
  int n = int(a.size());
  if (bit == -1 || n == 0) return;
  vector<long long> ones, zeros;
  int obz = 0, zbo = 0, o = 0, z = 0;
  for (int i = 0; i < n; i++) {
    if ((a[i] >> bit) & 1) {
      o++;
      inv[bit][1] += z;
      ones.push_back(a[i]);
    } else {
      z++;
      inv[bit][0] += o;
      zeros.push_back(a[i]);
    }
  }
  rec(ones, bit - 1);
  rec(zeros, bit - 1);
}
void solve() {
  int n;
  cin >> n;
  vector<long long> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  long long x = 0;
  long long invs = 0;
  rec(a, 30);
  for (int bit = 29; bit >= 0; bit--) {
    if (inv[bit][1] < inv[bit][0]) {
      invs += inv[bit][1];
      x |= (1ll << bit);
    } else {
      invs += inv[bit][0];
    }
  }
  cout << invs << " " << x << endl;
}
int main() {
  ios ::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  int tt = 1;
  for (int tc = 1; tc <= tt; tc++) {
    solve();
  }
}
