#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll cnt_inv[30][2];
void rec(vector<int>& a, int b) {
  if (b < 0 || a.empty()) return;
  vector<int> s, us;
  for (int& i : a) {
    int val = i & (1 << b);
    if (val)
      cnt_inv[b][1] += us.size(), s.push_back(i);
    else
      cnt_inv[b][0] += s.size(), us.push_back(i);
  }
  rec(s, b - 1);
  rec(us, b - 1);
}
void solve() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < int(n); i++) cin >> a[i];
  memset(cnt_inv, 0, sizeof cnt_inv);
  rec(a, 29);
  ll inv = 0, x = 0;
  for (int b = 29; b >= 0; b--) {
    inv += min(cnt_inv[b][0], cnt_inv[b][1]);
    int val = 1;
    if (cnt_inv[b][0] <= cnt_inv[b][1]) val = 0;
    x += (val << b);
  }
  cout << inv << " " << x << '\n';
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  solve();
}
