#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 5;
int n;
vector<int> a;
long long inv[32][2];
void solve(vector<int> &a, int depth) {
  if (depth < 0) return;
  if (a.size() == 0) return;
  vector<int> left, right;
  long long cnt0 = 0, cnt1 = 0, sum01 = 0, sum10 = 0;
  for (int i = 0; i < a.size(); ++i) {
    if (a[i] >> depth & 1) {
      cnt1++;
      sum01 += cnt0;
      right.push_back(a[i]);
    } else {
      cnt0++;
      sum10 += cnt1;
      left.push_back(a[i]);
    }
  }
  inv[depth][0] += sum01;
  inv[depth][1] += sum10;
  solve(left, depth - 1);
  solve(right, depth - 1);
}
int main() {
  scanf("%d", &n);
  a.resize(n);
  for (auto &x : a) cin >> x;
  solve(a, 31);
  long long ans = 0, x = 0;
  for (int i = 0; i <= 31; ++i) {
    if (inv[i][0] >= inv[i][1])
      ans += inv[i][1];
    else
      ans += inv[i][0], x |= (1 << i);
  }
  printf("%lld %lld\n", ans, x);
  return 0;
}
