#include <bits/stdc++.h>
using namespace std;
const long long MAXN = 3e5 + 69;
const long long LOGA = 31;
long long n;
long long trie[MAXN * 16][2], now;
vector<long long> g[MAXN * 16];
long long dp[LOGA][2];
void add(long long x) {
  long long v = 0;
  for (long long i = LOGA - 1; i >= 0; i--) {
    long long bit = (x >> i) & 1;
    if (!trie[v][bit]) trie[v][bit] = ++now;
    g[v].push_back(x);
    v = trie[v][bit];
    if (i == 0) g[v].push_back(x);
  }
}
void dfs(long long v, long long i) {
  if (i < 0) return;
  long long l = trie[v][0], r = trie[v][1];
  if (l) dfs(l, i - 1);
  if (r) dfs(r, i - 1);
  if (!l || !r) return;
  long long cnt = 0;
  long long cnt1 = 0;
  for (long long u : g[v]) {
    if ((u >> i) & 1)
      cnt1++;
    else
      cnt += cnt1;
  }
  dp[i][0] += cnt;
  dp[i][1] += 1ll * g[l].size() * g[r].size() - cnt;
}
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (long long i = 1, x; i <= n; i++) {
    cin >> x;
    add(x);
  }
  dfs(0, LOGA - 1);
  long long ans1 = 0, ans2 = 0;
  for (long long i = LOGA - 1; i >= 0; i--) {
    ans1 += min(dp[i][0], dp[i][1]);
    if (dp[i][0] > dp[i][1]) ans2 |= (1ll << i);
  }
  cout << ans1 << ' ' << ans2;
}
