#include <bits/stdc++.h>
using namespace std;
int n;
long long cnt[40][20];
long long inv, x;
void sol(vector<int> a, int pos) {
  if (a.empty()) return;
  if (pos == -1) return;
  vector<int> t, tt;
  t.clear();
  tt.clear();
  long long zero = 0, one = 0;
  long long cnt1 = 0, cnt2 = 0;
  for (auto x : a) {
    if ((x >> pos) & 1) {
      one++;
      cnt2 += zero;
      t.push_back(x);
    } else {
      zero++;
      cnt1 += one;
      tt.push_back(x);
    }
  }
  cnt[pos][0] += cnt1;
  cnt[pos][1] += cnt2;
  sol(t, pos - 1);
  sol(tt, pos - 1);
}
int main() {
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i <= n - 1; i++) cin >> a[i];
  sol(a, 30);
  for (int i = 0; i <= 30; i++) {
    if (cnt[i][0] > cnt[i][1]) x |= (1 << i);
    inv += min(cnt[i][0], cnt[i][1]);
  }
  cout << inv << ' ' << x << endl;
}
