#include <bits/stdc++.h>
using namespace std;
long long inversions(vector<int> &v) {
  int zeros = 0;
  long long inv = 0;
  for (int i = (int)v.size() - 1; i >= 0; i--) {
    zeros += (v[i] == 0);
    if (v[i] == 1) inv += zeros;
  }
  return inv;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  vector<vector<int>> v;
  vector<int> t;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    t.push_back(x);
  }
  v.push_back(t);
  long long ans = 0;
  int x = 0;
  for (int i = 30; i >= 0; i--) {
    vector<vector<int>> vv;
    long long a = 0, b = 0;
    for (auto &go : v) {
      vector<int> tmp;
      for (auto &g : go) {
        tmp.push_back((g & (1 << i)) != 0);
      }
      a += inversions(tmp);
      for (auto &g : tmp) {
        g = (1 - g);
      }
      b += inversions(tmp);
      vector<int> t1, t2;
      for (int j = 0; j < (int)tmp.size(); j++) {
        if (tmp[j] == 0)
          t1.push_back(go[j]);
        else
          t2.push_back(go[j]);
      }
      if (!t1.empty()) vv.push_back(t1);
      if (!t2.empty()) vv.push_back(t2);
    }
    if (a <= b) {
      ans += a;
    } else {
      ans += b;
      x |= (1 << i);
    }
    v = vv;
  }
  cout << ans << " " << x;
}
