#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
using ll = long long;
using pii = pair<int, int>;
const int MOD = 1e9 + 7;
const int INF = 1e9 + 1e2;
void fin() {}
const bool flag = 0;
const int N = 3e5 + 10;
int a[N];
ll cnt[2][30];
void calc(int cur, vector<int> p) {
  if (cur == -1 || p.empty()) {
    return;
  }
  int z = 0, o = 0;
  vector<int> l, r;
  for (int i : p) {
    if (a[i] >> cur & 1) {
      l.push_back(i), o++, cnt[1][cur] += z;
    } else {
      r.push_back(i), z++, cnt[0][cur] += o;
    }
  }
  calc(cur - 1, l), calc(cur - 1, r);
}
void ma1n() {
  int n;
  cin >> n;
  vector<int> p;
  for (int i = 0; i < n; ++i) {
    cin >> a[i], p.push_back(i);
  }
  calc(29, p);
  ll ans = 0, first = 0;
  for (int i = 0; i < 30; ++i) {
    if (cnt[1][i] < cnt[0][i]) {
      ans += cnt[1][i], first |= (1 << i);
    } else {
      ans += cnt[0][i];
    }
  }
  cout << ans << " " << first;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(nullptr), fin();
  int ts = 1;
  if (flag) {
    cin >> ts;
  }
  while (ts--) {
    ma1n();
  }
  return 0;
}
