#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  int64_t total = 0;
  int x = 0;
  vector<vector<int>> vcur = {a};
  for (int j = 29; j >= 0; j--) {
    int64_t sum0 = 0, sum1 = 0;
    vector<vector<int>> vnext;
    for (auto& v : vcur) {
      int cnt0 = 0, cnt1 = 0;
      vector<int> v0, v1;
      for (int b : v) {
        if (b & (1 << j))
          cnt1++, sum1 += cnt0, v1.push_back(b);
        else
          cnt0++, sum0 += cnt1, v0.push_back(b);
      }
      if (v0.size()) vnext.push_back(v0);
      if (v1.size()) vnext.push_back(v1);
    }
    if (sum0 <= sum1)
      total += sum0;
    else
      total += sum1, x |= (1 << j);
    vcur = vnext;
  }
  cout << total << " " << x << endl;
}
