#include <bits/stdc++.h>
#pragma GCC optimize(2)
using namespace std;
long long ans, b1, b2, n, xx;
int a[300500], b[300500], c[300500], aa[300500];
long long merge(int l, int r, int mid) {
  long long ans = 0;
  int i, b1 = 0, c1 = 0, b2 = 1, c2 = 1;
  for (i = l; i <= mid; ++i) b[++b1] = a[i];
  for (i = mid + 1; i <= r; ++i) c[++c1] = a[i];
  for (i = l; i <= r; ++i) {
    if (b1 >= b2 && (c1 + 1 == c2 || b[b2] <= c[c2]))
      a[i] = b[b2++];
    else {
      a[i] = c[c2++];
      ans += b1 - b2 + 1;
    }
  }
  return ans;
}
long long solve(int l, int r) {
  if (l == r) return 0;
  int mid = (l + r) >> 1;
  long long ans = 0;
  ans += solve(l, mid);
  ans += solve(mid + 1, r);
  ans += merge(l, r, mid);
  return ans;
}
void work(long long x) {
  ans = 0;
  long long yy = xx;
  for (int i = 1; i <= n; i++) a[i] = aa[i] ^ yy;
  b1 = solve(1, n);
  ans = 0;
  for (int i = 1; i <= n; i++) a[i] = aa[i] ^ yy ^ (1 << x);
  b2 = solve(1, n);
  if (b2 < b1) xx ^= (1 << x);
}
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &aa[i]);
  }
  for (long long i = 31; i >= 0; i--) work(i);
  for (int i = 1; i <= n; i++) a[i] = xx ^ aa[i];
  ans = 0;
  cout << solve(1, n) << " " << xx;
}
