#include <bits/stdc++.h>
using namespace std;
unsigned long long inv[32][2];
int idx = 1;
const int nax = 3e5 + 123;
unsigned long long cnt[nax * 32];
unsigned long long trie[nax * 32][2];
void add(int x) {
  for (int i = 32, node = 0; i-- > 0;) {
    bool bit = (bool)((x >> i) & 1);
    inv[i][bit] += cnt[trie[node][!bit]];
    if (trie[node][bit] == 0) trie[node][bit] = idx++;
    cnt[trie[node][bit]]++;
    node = trie[node][bit];
  }
}
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    add(x);
  }
  unsigned long long x = 0, inversions = 0;
  for (int i = 0; i < 32; i++) {
    if (inv[i][0] > inv[i][1]) x += (unsigned long long)(1ll << i);
    inversions += min(inv[i][0], inv[i][1]);
  }
  cout << inversions << " " << x << "\n";
  return 0;
}
