#include <bits/stdc++.h>
using namespace std;
int n, a[300010], f[300010], g[300010];
long long merge(int arr[], int temp[], int left, int mid, int right) {
  int i, j, k;
  long long 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++];
      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 count;
}
long long mergeSort(int arr[], int temp[], int left, int right) {
  int mid;
  long long count = 0;
  if (right > left) {
    mid = (right + left) / 2;
    count = mergeSort(arr, temp, left, mid);
    count += mergeSort(arr, temp, mid + 1, right);
    count += merge(arr, temp, left, mid + 1, right);
  }
  return count;
}
long long arrInversion(int arr[], int n) {
  int temp[n];
  return mergeSort(arr, temp, 0, n - 1);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    g[i] = a[i];
  }
  int ans = 0;
  long long res = arrInversion(g, n);
  for (int j = 29; j >= 0; j--) {
    int s = 1 << j;
    for (int i = 0; i < n; i++) {
      f[i] = a[i] ^ s;
      g[i] = a[i];
    }
    long long v = arrInversion(f, n);
    if (res > v) {
      res = v;
      for (int i = 0; i < n; i++) {
        a[i] = a[i] ^ s;
      }
      ans += s;
    }
  }
  cout << res << " " << ans << endl;
  return 0;
}
