#include <bits/stdc++.h>
using namespace std;
vector<int> q;
int n, x;
long long dp[32][2];
void rec(int bit, vector<int> v) {
  if (bit < 0 || v.empty()) return;
  vector<int> v0, v1;
  int zero = 0, one = 0;
  for (int i : v) {
    if (i & (1 << bit)) {
      v1.push_back(i);
      ++one;
      dp[bit][1] += zero;
    } else {
      v0.push_back(i);
      ++zero;
      dp[bit][0] += one;
    }
  }
  rec(bit - 1, v0);
  rec(bit - 1, v1);
  return;
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    int qq;
    scanf("%d", &qq);
    q.push_back(qq);
  }
  rec(29, q);
  long long tot = 0;
  for (int i = 0; i <= 29; ++i) {
    if (dp[i][0] <= dp[i][1])
      tot += dp[i][0];
    else
      x |= (1 << i), tot += dp[i][1];
  }
  printf("%lld %d\n", tot, x);
  return 0;
}
