#include <bits/stdc++.h>
using namespace std;
const int maxn = 4e6 + 5;
int trie[maxn][2];
int a[maxn], n, tot;
long long l[35], r[35], cnt[maxn];
void insert(int n) {
  int rt = 0;
  for (int i = 30; i >= 0; i--) {
    int tmp = (n >> i) & 1;
    if (!trie[rt][tmp]) trie[rt][tmp] = ++tot;
    if (tmp == 1)
      r[i] += cnt[trie[rt][0]];
    else
      l[i] += cnt[trie[rt][1]];
    cnt[trie[rt][tmp]]++;
    rt = trie[rt][tmp];
  }
}
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    insert(a[i]);
  }
  long long ans = 0, sum = 0;
  for (int i = 30; i >= 0; i--) {
    if (l[i] <= r[i])
      sum += l[i];
    else
      sum += r[i], ans |= (1 << i);
  }
  cout << sum << ' ' << ans << '\n';
}
