#include <bits/stdc++.h>
using namespace std;
const long long MAXN = 3e5 + 5;
long long a[MAXN], kkorz[MAXN], bit[MAXN];
long long n;
long long sum(long long idx) {
  long long res = 0;
  for (; idx > 0; idx -= (idx & (-idx))) res += bit[idx];
  return res;
}
void upd(long long idx, long long x) {
  for (; idx <= n; idx += (idx & (-idx))) bit[idx] += x;
}
long long countInv() {
  vector<pair<long long, long long>> v;
  for (long long i = 0; i < n; i++) v.push_back(make_pair(kkorz[i], i));
  sort(v.begin(), v.end());
  for (long long i = 0; i < n; i++) kkorz[v[i].second] = i + 1;
  long long res = 0;
  for (long long i = 1; i <= n; i++) bit[i] = 0;
  for (long long i = n - 1; i >= 0; i--) {
    res += sum(kkorz[i] - 1);
    upd(kkorz[i], 1);
  }
  return res;
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (long long i = 0; i < n; i++) cin >> a[i];
  long long maxbit = 32 - __builtin_clz(*max_element(a, a + n));
  for (long long i = 0; i < n; i++) kkorz[i] = a[i];
  long long ans = countInv(), minx = 0, x = 0;
  for (long long b = 0; b <= maxbit; b++) {
    long long tmp = x | (1 << b);
    for (long long i = 0; i < n; i++) kkorz[i] = a[i] ^ tmp;
    long long i1 = countInv();
    if (i1 < ans) {
      x |= (1 << b);
      ans = i1;
      minx = x;
    }
  }
  cout << ans << " " << minx << "\n";
}
