#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
const int INF = 0x7fffffff;
const int N = 3e5 + 10;
int n, tot;
int trie[31 * N][2], sz[31 * N];
long long dp[31][2];
void insert(int x) {
  int rt = 0;
  for (int i = 30; i >= 0; --i) {
    int p = (x >> i) & 1;
    dp[i][p] += sz[trie[rt][p ^ 1]];
    if (trie[rt][p] == 0) trie[rt][p] = ++tot;
    rt = trie[rt][p];
    ++sz[rt];
  }
}
int main(void) {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  cin >> n;
  for (int i = 0; i < n; ++i) {
    int x;
    cin >> x;
    insert(x);
  }
  long long sum = 0;
  int res = 0;
  for (int i = 30; i >= 0; --i) {
    if (dp[i][1] < dp[i][0]) {
      res |= 1 << i;
      sum += dp[i][1];
    } else
      sum += dp[i][0];
  }
  cout << sum << " " << res << '\n';
  return 0;
}
