#include <bits/stdc++.h>
using namespace std;
const int MAXN = 3e5 + 5;
int a[MAXN], b[MAXN], temp[MAXN];
int n, ans;
inline long long MergeSort(int l, int r) {
  if (l == r) return 0;
  int i = l, j = ((l + r) >> 1) + 1, pst = l;
  long long subans =
      MergeSort(l, ((l + r) >> 1)) + MergeSort(((l + r) >> 1) + 1, r);
  while (i <= ((l + r) >> 1) && j <= r) {
    if (a[i] <= a[j])
      temp[pst++] = a[i++];
    else
      temp[pst++] = a[j++], subans += ((l + r) >> 1) - i + 1;
  }
  while (i <= ((l + r) >> 1)) temp[pst++] = a[i++];
  while (j <= r) temp[pst++] = a[j++];
  for (int i = l; i <= r; i++) a[i] = temp[i];
  return subans;
}
inline long long InversePair(int x) {
  for (int i = 1; i <= n; i++) a[i] = b[i] ^ x;
  return MergeSort(1, n);
}
signed main(void) {
  cin >> n;
  for (int i = 1; i <= n; i++) scanf("%d", b + i);
  long long base = InversePair(0);
  for (int i = 0; i <= 31; i++) {
    long long sub = InversePair(1 << i);
    if (sub < base) ans += (1 << i);
  }
  printf("%lld %d\n", InversePair(ans), ans);
  return 0;
}
