#include <bits/stdc++.h>
using namespace std;
const int mxN = 1e5 + 7;
const int inf = 1e9 + 7;
const int mod = 1e9 + 7;
void solve() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) cin >> a[i];
  vector<long long> zero(31, 0), one(31, 0);
  function<void(vector<int> &, int)> rec = [&](vector<int> &t, int b) {
    int m = t.size();
    if (b < 0 || m == 0) return;
    vector<int> z, o;
    int x = 0, y = 0;
    for (int i = 0; i < m; ++i) {
      if ((t[i] >> b) & 1) {
        ++y;
        one[b] += x;
        o.push_back(t[i]);
      } else {
        ++x;
        zero[b] += y;
        z.push_back(t[i]);
      }
    }
    rec(z, b - 1);
    rec(o, b - 1);
  };
  rec(a, 30);
  long long inv = 0, num = 0;
  for (int i = 30; i >= 0; --i) {
    inv += min(zero[i], one[i]);
    num |= (zero[i] <= one[i] ? 0 : (1 << i));
  }
  cout << inv << ' ' << num << '\n';
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int T = 1;
  for (int tt = 1; tt <= T; ++tt) {
    solve();
  }
  return 0;
}
