#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int N, A[300005], B[300005], C[300005];
ll mergesort(int s, int e) {
  if (s == e) return 0;
  int mid = (s + e) >> 1;
  ll res = mergesort(s, mid) + mergesort(mid + 1, e);
  for (int i = s; i <= e; i++) C[i] = B[i];
  int i1 = s, i2 = mid + 1;
  for (int x = 0; x <= e - s; x++) {
    if (i1 > mid) {
      B[s + x] = C[i2++];
    } else if (i2 > e) {
      B[s + x] = C[i1++];
      res += i2 - mid - 1;
    } else if (C[i1] <= C[i2]) {
      B[s + x] = C[i1++];
      res += i2 - mid - 1;
    } else {
      B[s + x] = C[i2++];
    }
  }
  return res;
}
ll go(int bit) {
  for (int i = 1; i <= N; i++) B[i] = (A[i] ^ bit);
  return mergesort(1, N);
}
int main() {
  scanf("%d", &N);
  for (int i = 1; i <= N; i++) scanf("%d", A + i);
  int ans = 0;
  ll cur = go(0);
  for (int i = 30; ~i; i--) {
    ll res = go(ans | (1 << i));
    if (cur > res) {
      cur = res;
      ans |= (1 << i);
    }
  }
  printf("%lld %d\n", cur, ans);
}
