#include <bits/stdc++.h>
using namespace std;
int N;
vector<vector<pair<int, int> > > v, nv;
long long count_inversions(const vector<pair<int, int> >& v0,
                           const vector<pair<int, int> >& v1) {
  long long ans = 0;
  int pos = 0;
  for (int i = 0; i < (v0.size()); i++) {
    while (pos < (int)v1.size() && v0[i].second >= v1[pos].second) pos++;
    ans += pos;
  }
  return ans;
}
int main(int argc, char* argv[]) {
  scanf("%d", &N);
  v.push_back(vector<pair<int, int> >());
  for (int i = 0; i < (N); i++) {
    int a;
    scanf("%d", &a);
    v[0].push_back(make_pair(a, i));
  }
  long long ans = 0;
  int x = 0;
  for (int b = (30); b >= (0); b--) {
    long long inv0 = 0, inv1 = 0;
    for (int i = 0; i < (v.size()); i++) {
      vector<pair<int, int> > v0, v1;
      for (int j = 0; j < (v[i].size()); j++) {
        if (v[i][j].first & (1 << b))
          v1.push_back(v[i][j]);
        else
          v0.push_back(v[i][j]);
      }
      long long inv = count_inversions(v0, v1);
      inv0 += inv;
      inv1 += (long long)v0.size() * (long long)v1.size() - inv;
      if (v0.size()) nv.push_back(v0);
      if (v1.size()) nv.push_back(v1);
    }
    if (inv0 > inv1) x |= (1 << b);
    ans += min(inv0, inv1);
    v = nv;
    nv.clear();
  }
  cout << ans << " " << x << endl;
  return 0;
}
