#include <bits/stdc++.h>
using namespace std;
long long power(long long x, long long y) {
  long long res = 1;
  while (y > 0) {
    if (y & 1) res = (res * x) % 998244353;
    y = y / 2;
    if (y != 0) x = (x * x) % 998244353;
  }
  return res;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long t, n, i, j, o, e, ans = 0, num, ans1, ans2, sz, x = 0, chk;
  cin >> n;
  long long a;
  vector<long long> v;
  for (i = 0; i < n; i++) {
    cin >> a;
    v.push_back(a);
  }
  queue<vector<long long> > q;
  q.push(v);
  long long bit = 30;
  while (bit >= 0) {
    sz = q.size();
    chk = 1ll << bit;
    ans1 = ans2 = 0;
    for (i = 0; i < sz; i++) {
      v = q.front();
      q.pop();
      vector<long long> one, zero;
      o = e = 0;
      for (j = 0; j < v.size(); j++) {
        num = v[j];
        if (num & chk) {
          one.push_back(v[j]);
          o++;
          ans2 += e;
        } else {
          zero.push_back(v[j]);
          e++;
          ans1 += o;
        }
      }
      if (!one.empty()) q.push(one);
      if (!zero.empty()) q.push(zero);
    }
    ans += min(ans1, ans2);
    if (ans1 > ans2) x += chk;
    bit--;
  }
  cout << ans << " " << x << "\n";
  return 0;
}
