#include <bits/stdc++.h>
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
void err(istream_iterator<string> it) { cout << '\n'; }
template <typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
  cerr << "[" << *it << " = " << a << "] ";
  err(++it, args...);
}
pair<int, int> dx[] = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};
const int inf = 2e9 + 7;
const long long INF = 3e18 + 7;
const long double pi = 3.1415926535897932384626433;
const double eps = 1e-6;
const long double EPS = 1e-9;
long long mod = 998244353;
const long long MOD = 1e15 + 7;
const bool multiple_tests = 0;
const int N = 1e6 + 7;
long long bp(long long a, long long n) {
  if (n == 0) return 1;
  long long res = bp(a, n / 2);
  res = res * res % mod;
  if (n % 2) res = res * a % mod;
  return res;
}
long long _mergeSort(long long arr[], long long temp[], long long left,
                     long long right);
long long merge(long long arr[], long long temp[], long long left,
                long long mid, long long right);
long long mergeSort(long long arr[], long long array_size) {
  long long temp[array_size];
  return _mergeSort(arr, temp, 0, array_size - 1);
}
long long _mergeSort(long long arr[], long long temp[], long long left,
                     long long right) {
  long long mid, inv_count = 0;
  if (right > left) {
    mid = (right + left) / 2;
    inv_count += _mergeSort(arr, temp, left, mid);
    inv_count += _mergeSort(arr, temp, mid + 1, right);
    inv_count += merge(arr, temp, left, mid + 1, right);
  }
  return inv_count;
}
long long merge(long long arr[], long long temp[], long long left,
                long long mid, long long right) {
  long long i, j, k;
  long long inv_count = 0;
  i = left;
  j = mid;
  k = left;
  while ((i <= mid - 1) && (j <= right)) {
    if (arr[i] <= arr[j]) {
      temp[k++] = arr[i++];
    } else {
      temp[k++] = arr[j++];
      inv_count = inv_count + (mid - i);
    }
  }
  while (i <= mid - 1) temp[k++] = arr[i++];
  while (j <= right) temp[k++] = arr[j++];
  for (i = left; i <= right; i++) arr[i] = temp[i];
  return inv_count;
}
long long inve(long long a[], long long n) {
  long long b[n];
  for (long long i = 0; i < n; i++) b[i] = a[i];
  return mergeSort(b, n);
}
void solve() {
  long long n;
  cin >> n;
  long long a[n], mx = 0;
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
    mx = max(mx, (long long)log2(a[i] + 1));
  }
  long long ans = 0, prev = inve(a, n);
  for (long long i = 0; i <= min(30ll, mx + 1); i++) {
    long long b[n];
    ans ^= (1 << i);
    for (long long j = 0; j < n; j++) {
      b[j] = a[j] ^ ans;
    }
    long long invs1 = inve(b, n);
    ans ^= (1 << i);
    if (prev > invs1) {
      ans ^= (1 << i);
      prev = invs1;
    }
  }
  cout << prev << ' ' << ans;
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long TT = 1;
  if (multiple_tests) cin >> TT;
  for (long long testcase = 1; testcase <= TT; testcase++) {
    solve();
    cout << '\n';
  }
  return 0;
}
