#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 10;
int n;
long long ans = 0, res = 0;
long long a[N], s1[N], s2[N], b[N];
long long x[N], y[N];
void solve(int l, int r, int k) {
  if (k < 0 || l > r) return;
  s1[l - 1] = s2[l - 1] = 0;
  int cnt = 0, tot = l;
  for (int i = l; i <= r; i++) {
    s1[i] = s1[i - 1];
    s2[i] = s2[i - 1];
    if (a[i] >> k & 1)
      s1[i]++, y[k] += s2[i - 1];
    else
      s2[i]++, x[k] += s1[i - 1];
  }
  for (int i = l; i <= r; i++)
    if (a[i] >> k & 1) b[tot++] = a[i];
  int mid = tot - 1;
  for (int i = l; i <= r; i++)
    if (!(a[i] >> k & 1)) b[tot++] = a[i];
  for (int i = l; i <= r; i++) a[i] = b[i];
  solve(l, mid, k - 1);
  solve(mid + 1, r, k - 1);
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  solve(1, n, 30);
  for (int k = 0; k <= 30; k++) {
    if (x[k] > y[k]) {
      ans += 1 << k;
    }
    res += min(x[k], y[k]);
  }
  printf("%lld %lld\n", res, ans);
  return 0;
}
