#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 5;
const int C = 30 + 5;
const int M = N * 30 + 5;
const int INF = 0x3f3f3f3f;
const long long INF_LL = 0x3f3f3f3f3f3f3f3f;
int ch[M][2];
vector<int> pos[M];
int nidx = 0;
int rt = 0;
void Insert(int &o, int dep, int x, int _pos) {
  if (o == 0) o = ++nidx;
  if (dep < 0) {
    pos[o].push_back(_pos);
    return;
  }
  int op = (x >> dep) & 1;
  Insert(ch[o][op], dep - 1, x, _pos);
}
long long f[C][2];
void DFS(int o, int dep, vector<int> &vec) {
  if (pos[o].size()) {
    vec = pos[o];
  } else {
    vector<int> a, b;
    if (ch[o][0]) DFS(ch[o][0], dep - 1, a);
    if (ch[o][1]) DFS(ch[o][1], dep - 1, b);
    for (auto x : b)
      f[dep][0] += lower_bound(a.begin(), a.end(), x) - a.begin();
    for (auto x : a)
      f[dep][1] += lower_bound(b.begin(), b.end(), x) - b.begin();
    vec.resize(a.size() + b.size());
    merge(a.begin(), a.end(), b.begin(), b.end(), vec.begin());
  }
}
int a[N];
long long sumInv = 0;
void Merge(int L, int R, vector<int> &vec) {
  if (L == R) {
    vec.push_back(a[L]);
  } else {
    vector<int> l, r;
    int M = (L + R) / 2;
    Merge(L, M, l);
    Merge(M + 1, R, r);
    for (auto x : l) sumInv += lower_bound(r.begin(), r.end(), x) - r.begin();
    vec.resize(l.size() + r.size());
    merge(l.begin(), l.end(), r.begin(), r.end(), vec.begin());
  }
}
int main() {
  ios::sync_with_stdio(0);
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    Insert(rt, 30, a[i], i);
  }
  vector<int> vec;
  DFS(rt, 30, vec);
  vec.clear();
  Merge(1, n, vec);
  int ans = 0;
  for (int i = 30; i >= 0; i--) {
    if (f[i][0] - f[i][1] < 0) {
      ans |= 1 << i;
      sumInv += f[i][0] - f[i][1];
    }
  }
  cout << sumInv << ' ' << ans << endl;
  return 0;
}
