#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n;
  scanf("%lld", &n);
  vector<long long> a;
  for (long long i = 0; i < n; i++) {
    long long x;
    scanf("%lld", &x);
    a.push_back(x);
  }
  long long x = 0;
  long long ans = 0;
  unordered_map<long long, long long> mapa;
  for (long long i = 29; i >= 0; i--) {
    mapa.reserve(2 * n);
    long long ones = 0;
    long long zeros = 0;
    for (long long j = 0; j < n; j++) {
      long long here = a[j];
      long long z = (1 << i) - 1;
      here |= z;
      long long xorv = (1 << i);
      if (here & (xorv)) {
        ones += mapa[here ^ xorv];
      } else {
        zeros += mapa[here ^ xorv];
      }
      mapa[here]++;
    }
    mapa.clear();
    if (ones < zeros) {
      x |= (1 << i);
    }
    ans += min(ones, zeros);
  }
  cout << ans << " " << x << endl;
}
