#include <bits/stdc++.h>
using namespace std;
const int N = 30 * 300005;
int cur = 0, g[N][2], sz[N];
long long dp[30][2];
int n;
void ins(int x) {
  int curr = 0;
  for (int i = 29; i >= 0; i--) {
    int b = ((1 << i) & x) ? 1 : 0;
    if (g[curr][!b]) {
      dp[i][b] += sz[g[curr][!b]];
    }
    if (!g[curr][b]) g[curr][b] = ++cur;
    curr = g[curr][b];
    sz[curr]++;
  }
}
int32_t main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    int x;
    scanf("%d", &x);
    ins(x);
  }
  long long ans = 0, x = 0;
  for (int i = 29; i >= 0; i--) {
    if (dp[i][0] > dp[i][1]) x ^= (1LL << i);
    ans += min(dp[i][0], dp[i][1]);
  }
  printf("%lld %lld\n", ans, x);
}
