#include <bits/stdc++.h>
using namespace std;
long long op[30][2];
void go(vector<int>& a, int b) {
  if (b == -1 || a.empty()) return;
  int ls = 0, os = 0;
  long long inv = 0, inv1 = 0;
  vector<int> g[2];
  for (int& i : a) {
    g[i >> b & 1].push_back(i);
    os += !(i >> b & 1);
    ls += (i >> b & 1);
    if (i >> b & 1)
      inv1 += os;
    else
      inv += ls;
  }
  op[b][0] += inv;
  op[b][1] += inv1;
  go(g[0], b - 1);
  go(g[1], b - 1);
}
int main() {
  int n;
  scanf("%d", &n);
  vector<int> a(n);
  for (int& i : a) scanf("%d", &i);
  go(a, 29);
  int x = 0;
  long long inv = 0;
  for (int b = 29; ~b; b--) {
    inv += min(op[b][0], op[b][1]);
    if (op[b][0] > op[b][1]) x |= 1 << b;
  }
  printf("%I64d %d\n", inv, x);
}
