#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 5;
long long f[32][2];
void dp(int b, vector<int> v) {
  if (b == -1 || v.empty()) return;
  int zero = 0, one = 0;
  vector<int> v0, v1;
  for (int x : v) {
    if (x >> b & 1) {
      v1.push_back(x);
      ++one;
      f[b][1] += zero;
    } else {
      v0.push_back(x);
      ++zero;
      f[b][0] += one;
    }
  }
  dp(b - 1, v0);
  dp(b - 1, v1);
}
int main() {
  int n;
  scanf("%d", &n);
  vector<int> a(n);
  for (int i = 0; i < n; ++i) scanf("%d", &a[i]);
  dp(30, a);
  long long inv = 0;
  int x = 0;
  for (int i = 30; i >= 0; --i) {
    if (f[i][1] < f[i][0])
      x |= 1 << i, inv += f[i][1];
    else
      inv += f[i][0];
  }
  printf("%lld %d\n", inv, x);
  return 0;
}
