#include <bits/stdc++.h>
using namespace std;
int a[300005], root = 1, cnt = 1, ch[10000005][2], siz[10000005];
long long res[35][2];
void insert(int x) {
  int now = 1;
  for (int i = 30; i >= 0; i--) {
    int c = ((x >> i) & 1);
    if (c == 0)
      res[i][0] += siz[ch[now][1]];
    else
      res[i][1] += siz[ch[now][0]];
    if (!ch[now][c]) ch[now][c] = ++cnt;
    siz[now]++;
    now = ch[now][c];
  }
  siz[now]++;
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]), insert(a[i]);
  long long ans = 0;
  int x = 0;
  for (int i = 30; i >= 0; i--) {
    if (res[i][1] < res[i][0])
      x |= (1 << i), ans += res[i][1];
    else
      ans += res[i][0];
  }
  printf("%lld %d", ans, x);
  return 0;
}
