#include <bits/stdc++.h>
int n, a[300000], b[300000], s[2][300000];
long long x[30], y[30];
void work(int l, int r, int lv) {
  if (lv == -1) return;
  if (l == r) return;
  int s0 = 0, s1 = 0;
  for (int i = l, k = l; i < r; i++) {
    if (a[b[i]] & (1 << lv)) {
      s[1][s1++] = b[i];
      y[lv] += s0;
    } else {
      s[0][s0++] = b[i];
      x[lv] += s1;
    }
  }
  for (int i = 0; i < s0; i++) b[l + i] = s[0][i];
  for (int i = 0; i < s1; i++) b[l + s0 + i] = s[1][i];
  work(l, l + s0, lv - 1);
  work(l + s0, r, lv - 1);
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", a + i);
    b[i] = i;
  }
  work(0, n, 30 - 1);
  long long ans = 0;
  int t = 0;
  for (int i = 30 - 1; i >= 0; i--) {
    if (x[i] <= y[i]) {
      ans += x[i];
    } else {
      ans += y[i];
      t |= (1 << i);
    }
  }
  printf("%lld %d\n", ans, t);
}
