#include <bits/stdc++.h>
using namespace std;
int m[31], mask = 0;
struct num {
  int v, idx;
  bool operator<(const num &o) const {
    if ((v & mask) != (o.v & mask)) return (v & mask) < (o.v & mask);
    return idx < o.idx;
  }
};
num a[300001];
int main() {
  m[1] = 1;
  for (int i = 2; i <= 30; ++i) m[i] = m[i - 1] * 2;
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) scanf("%d", &a[i].v), a[i].idx = i;
  long long rescnt = 0;
  int resnum = 0;
  mask = 0;
  for (int i = 30; i >= 1; --i) {
    sort(a, a + n);
    long long zero = 0, one = 0;
    long long cnt_zero = 0, cnt_one = 0;
    for (int j = 0; j < n; ++j) {
      if (j != 0 && (a[j].v & mask) != (a[j - 1].v & mask)) {
        cnt_zero = 0;
        cnt_one = 0;
      }
      if ((a[j].v & m[i]) == 0) {
        ++cnt_one;
        zero += cnt_zero;
      } else {
        ++cnt_zero;
        one += cnt_one;
      }
    }
    if (one < zero) {
      rescnt += one;
      resnum += m[i];
    } else {
      rescnt += zero;
    }
    mask += m[i];
  }
  printf("%lld %d\n", rescnt, resnum);
}
