#include <bits/stdc++.h>
using namespace std;
const int maxn = 4e6 + 10;
int tot = 0, trie[maxn][3];
vector<int> v[maxn];
int n, a[maxn];
long long dp[50][3], ans1, ans2;
void Insert(int x, int pos) {
  int p = 0, tmp;
  for (int i = 30; i >= 0; i--) {
    tmp = (x >> i) & 1;
    if (trie[p][tmp] == 0) trie[p][tmp] = ++tot;
    p = trie[p][tmp];
    v[p].push_back(pos);
  }
}
void dfs(int p, int pos) {
  if (pos == -1) return;
  int l = trie[p][0], r = trie[p][1];
  long long sz0 = v[l].size(), sz1 = v[r].size();
  long long ans = 0, tmp = 0;
  for (int i = 0; i < sz0; i++) {
    if (!sz1) break;
    while (tmp < sz1 && v[r][tmp] < v[l][i]) tmp++;
    ans += tmp;
  }
  dp[pos][0] += ans;
  dp[pos][1] += sz1 * sz0 - ans;
  if (l != 0) dfs(l, pos - 1);
  if (r != 0) dfs(r, pos - 1);
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    Insert(a[i], i);
  }
  dfs(0, 30);
  for (int i = 0; i <= 30; i++) {
    if (dp[i][0] <= dp[i][1]) {
      ans1 += dp[i][0];
    } else {
      ans1 += dp[i][1];
      ans2 += (1 << i);
    }
  }
  printf("%lld %lld\n", ans1, ans2);
}
