#include <bits/stdc++.h>
using namespace std;
int n;
vector<int> a;
long long int cnt[33][2];
long long int inv, amid;
bool added[33];
void solve(vector<int> v, int bit) {
  if (bit == -1 || v.empty()) return;
  vector<int> v0, v1;
  int b0 = 0, b1 = 0;
  for (auto x : v) {
    bool f = bool(x & (1 << bit));
    if (f) {
      b1++;
      cnt[bit][0] += b0;
    } else {
      b0++;
      cnt[bit][1] += b1;
    }
    if (f)
      v1.push_back(x);
    else
      v0.push_back(x);
  }
  solve(v0, bit - 1);
  solve(v1, bit - 1);
}
void test_case() {
  scanf("%d", &n);
  a.resize(n);
  for (int i = 0; i < n; i++) scanf("%d", &a[i]);
  solve(a, 30);
  for (int i = 0; i < 30; i++) {
    if (cnt[i][0] < cnt[i][1]) amid += (1 << i);
    inv += min(cnt[i][0], cnt[i][1]);
  }
  cout << inv << " " << amid << '\n';
}
int main() {
  int t = 1;
  while (t--) test_case();
}
