#include <bits/stdc++.h>
using namespace std;
long long n, x, y, sol;
vector<long long> v;
long long arr[32][2];
void rek(long long bit, vector<long long> a) {
  if (bit == -1 || a.size() == 0) {
    return;
  }
  vector<long long> zero;
  vector<long long> one;
  long long m = a.size();
  for (long long i = 0; i < m; i++) {
    if ((1 << bit) & a[i]) {
      one.push_back(a[i]);
    } else {
      zero.push_back(a[i]);
    }
  }
  long long cnt = 0;
  long long ostalo = 0;
  for (long long i = 0; i < m; i++) {
    if ((1 << bit) & a[i]) {
      ostalo++;
    } else {
      cnt += ostalo;
    }
  }
  arr[bit][1] += cnt;
  cnt = 0;
  ostalo = 0;
  for (long long i = 0; i < m; i++) {
    if ((1 << bit) & a[i]) {
      cnt += ostalo;
    } else {
      ostalo++;
    }
  }
  arr[bit][0] += cnt;
  rek(bit - 1, zero);
  rek(bit - 1, one);
}
int main() {
  cin >> n;
  for (long long i = 0; i < n; i++) {
    cin >> y;
    v.push_back(y);
  }
  rek(31, v);
  x = 0;
  sol = 0;
  for (long long i = 0; i < 30; i++) {
    if (arr[i][1] > arr[i][0]) {
      x += (1 << i);
    }
    sol += min(arr[i][0], arr[i][1]);
  }
  cout << sol << " " << x << "\n";
  return 0;
}
