#include <bits/stdc++.h>
using namespace std;
long long getinv(vector<int>& val) {
  long long res = 0;
  long long cntone = 0;
  for (int i = 0; i < val.size(); ++i) {
    if (val[i] == 0) {
      res += cntone;
    } else {
      ++cntone;
    }
  }
  return res;
}
long long getinv(vector<vector<int> >& cur, int x) {
  long long res = 0;
  for (int i = 0; i < cur.size(); ++i) {
    vector<int> nv = cur[i];
    if (x == 1) {
      for (int j = 0; j < nv.size(); ++j) {
        nv[j] = 1 - nv[j];
      }
    }
    res += getinv(nv);
  }
  return res;
}
void solve() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  long long ans = 0;
  long long val = 0;
  vector<vector<int> > cur;
  cur.push_back(a);
  for (int ps = 29; ps >= 0; --ps) {
    vector<vector<int> > nv;
    for (int i = 0; i < cur.size(); ++i) {
      vector<int> ncur(cur[i].size(), 0);
      for (int j = 0; j < cur[i].size(); ++j) {
        ncur[j] = (bool)(cur[i][j] & (1 << ps));
      }
      nv.push_back(ncur);
    }
    long long rs1 = getinv(nv, 0);
    long long rs2 = getinv(nv, 1);
    if (rs2 < rs1) {
      ans += rs2;
      val += (1 << ps);
    } else {
      ans += rs1;
    }
    vector<vector<int> > nvi;
    for (int i = 0; i < cur.size(); ++i) {
      vector<int> nv1;
      vector<int> nv2;
      for (int j = 0; j < cur[i].size(); ++j) {
        if (cur[i][j] & (1 << ps)) {
          nv1.push_back(cur[i][j]);
        } else {
          nv2.push_back(cur[i][j]);
        }
      }
      if (!nv1.empty()) {
        nvi.push_back(nv1);
      }
      if (!nv2.empty()) {
        nvi.push_back(nv2);
      }
    }
    cur = nvi;
  }
  cout << ans << " " << val << endl;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int t;
  t = 1;
  for (int tt = 0; tt < t; ++tt) {
    solve();
  }
  return 0;
}
