#include <bits/stdc++.h>
using namespace std;
const int N = 300005;
int n;
int a[N], x;
long long ans, res[2];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int j = 29; j >= 0; j--) {
    unordered_map<int, int> cnt[2];
    cnt[0].reserve(2 * n);
    cnt[1].reserve(2 * n);
    res[0] = res[1] = 0;
    for (int i = 1; i <= n; i++) {
      int val = !!((1 << j) & a[i]);
      int num = a[i] >> (j + 1);
      res[val] += cnt[!val][num];
      cnt[val][num]++;
    }
    x *= 2;
    x += (res[0] > res[1]);
    ans += min(res[0], res[1]);
  }
  cout << ans << " " << x << endl;
  return 0;
}
