#include <bits/stdc++.h>
using namespace std;
int n, stb;
long long ans, c;
long long count_now = 0, count_xr = 0;
bool y, z;
vector<int> vc;
vector<int> a;
unordered_map<int, int> mp;
void count(long long j) {
  mp.clear();
  count_now = 0, count_xr = 0;
  for (int i = 0; i < n; i++) {
    y = (a[i] >> j) & 1;
    if (y == 0) {
      if (mp.find(vc[i]) != mp.end()) count_now += mp[vc[i]];
    } else {
      mp[vc[i]]++;
    }
  }
  mp.clear();
  for (int i = 0; i < n; i++) {
    z = ((a[i] >> j) & 1) ^ 1;
    if (z == 0) {
      if (mp.find(vc[i]) != mp.end()) count_xr += mp[vc[i]];
    } else {
      mp[vc[i]]++;
    }
  }
  int f = (1 << j);
  for (int i = 0; i < n; i++) {
    y = (a[i] >> j) & 1;
    z = ((a[i] >> j) & 1) ^ 1;
    vc[i] += (count_now < count_xr ? (y * f) : (z * f));
  }
  c += min(count_now, count_xr);
  if (count_now > count_xr) {
    ans += (long long)(f);
  }
}
int main() {
  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  ;
  cin >> n;
  a.resize(n);
  vc.resize(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    for (int j = 30; j >= 0; j--) {
      if ((a[i] >> j) & 1) {
        stb = max(stb, j);
      }
    }
  }
  for (int j = stb; j >= 0; j--) {
    count(j);
  }
  cout << c << " " << ans << "\n";
}
