#include <bits/stdc++.h>
using namespace std;
const long long inf = 0x3f3f3f3f;
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n;
  cin >> n;
  vector<long long> nums(n);
  for (long long i = 0; i < n; i++) cin >> nums[i];
  vector<vector<long long> > gs;
  gs.push_back(nums);
  long long ans = 0, ansi = 0;
  for (long long b = 31; b >= 0; b--) {
    vector<vector<long long> > ngs;
    long long oi = 0, zi = 0;
    long long bi = 1 << b;
    for (auto ns : gs) {
      long long o = 0, z = 0;
      vector<long long> ones, zeros;
      for (auto x : ns) {
        if (x & bi) {
          o++;
          oi += z;
          ones.push_back(x);
        } else {
          z++;
          zi += o;
          zeros.push_back(x);
        }
      }
      if (!ones.empty()) ngs.push_back(ones);
      if (!zeros.empty()) ngs.push_back(zeros);
    }
    gs = ngs;
    if (oi >= zi) {
      ansi += zi;
    } else {
      ans |= bi;
      ansi += oi;
    }
  }
  cout << ansi << ' ' << ans << endl;
}
