#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
const double err = 1e-10;
const int N = 1e5 + 5;
long long inversions = 0, x = 0, n;
long long inv[31][2];
void rec(vector<int> &V, int bit) {
  if (V.empty() || bit < 0) return;
  long long c0 = 0, c1 = 0, inv0 = 0, inv1 = 0;
  vector<int> zV, oV;
  for (int i = 0; i < V.size(); i++) {
    if (V[i] & (1 << bit)) {
      inv1 += c0;
      c1++;
      oV.push_back(V[i]);
    } else {
      inv0 += c1;
      c0++;
      zV.push_back(V[i]);
    }
  }
  inv[bit][0] += inv0;
  inv[bit][1] += inv1;
  rec(oV, bit - 1);
  rec(zV, bit - 1);
}
void solve() {
  memset(inv, 0, sizeof(inv));
  cin >> n;
  vector<int> V(n);
  for (int i = 0; i < n; i++) cin >> V[i];
  rec(V, 30);
  for (int i = 0; i < 31; i++) {
    if (inv[i][1] < inv[i][0]) x += (1 << i);
    inversions += min(inv[i][1], inv[i][0]);
  }
  cout << inversions << ' ' << x << endl;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int T = 1;
  while (T--) solve();
  return 0;
}
