#include <bits/stdc++.h>
using namespace std;
int n;
long long *a;
long long ans, tz;
long long su[2][64];
void calc(long long *a, int len, int now) {
  if (!len) {
    free(a);
    return;
  }
  if (now < 0) {
    free(a);
    return;
  }
  long long temp[2][2];
  for (int i = 0; i < 2; i++)
    for (int j = 0; j < 2; j++) temp[i][j] = 0;
  for (int i = 0; i < len; i++) {
    long long tz = a[i] >> now;
    temp[0][tz % 2] += temp[1][(tz + 1) % 2];
    temp[1][tz % 2]++;
  }
  su[1][now] += temp[0][0];
  su[0][now] += temp[0][1];
  long long *b, *c;
  b = (long long *)malloc(temp[1][0] * sizeof(long long));
  c = (long long *)malloc(temp[1][1] * sizeof(long long));
  int cot[2];
  cot[0] = cot[1] = 0;
  for (int i = 0; i < len; i++) {
    long long tz = a[i] >> now;
    if (tz % 2) {
      c[cot[1]++] = a[i];
    } else {
      b[cot[0]++] = a[i];
    }
  }
  free(a);
  calc(b, cot[0], now - 1);
  calc(c, cot[1], now - 1);
}
int main() {
  scanf("%d", &n);
  a = (long long *)malloc(n * sizeof(long long));
  for (int i = 0; i < n; i++) scanf("%lld", &a[i]);
  calc(a, n, 35);
  ans = 0;
  for (int i = 0; i < 35; i++) {
    tz += min(su[1][i], su[0][i]);
    if (su[1][i] > su[0][i]) ans += ((long long)1 << i);
  }
  printf("%lld %lld", tz, ans);
}
