#include <bits/stdc++.h>
using namespace std;
long long int inv[32][2];
void rec(vector<int>& a, int b) {
  if (b < 0 || a.size() == 0) return;
  int c[2] = {0};
  vector<int> v[2];
  for (int x : a) {
    int val;
    if ((x & (1 << b)) > 0)
      val = 1;
    else
      val = 0;
    if (val == 0)
      inv[b][0] += c[1];
    else
      inv[b][1] += c[0];
    c[val]++;
    v[val].push_back(x);
  }
  rec(v[0], b - 1);
  rec(v[1], b - 1);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  rec(a, 30);
  long long int x = 0, ans = 0;
  for (int i = 0; i <= 30; i++) {
    ans += min(inv[i][0], inv[i][1]);
    if (inv[i][0] > inv[i][1]) x += (1 << i);
  }
  cout << ans << " " << x << "\n";
}
