#include <bits/stdc++.h>
using namespace std;
int n, a[300100];
long long sum[40];
void solve(vector<int> a, int bit) {
  int n = a.size();
  if (n == 0 || bit < 0) return;
  vector<int> v0, v1;
  long long num1 = 0, sum1 = 0, num0 = 0, sum0 = 0;
  for (int i = 0; i < n; i++)
    if ((a[i] >> bit) & 1)
      num1++, sum1 += num0, v1.push_back(a[i]);
    else
      num0++, sum0 += num1, v0.push_back(a[i]);
  sum[bit] += sum0 - sum1;
  solve(v0, bit - 1);
  solve(v1, bit - 1);
}
int x[300100], b[300100];
void modify(int x, int k) {
  for (; x <= n; x += (x & -x)) b[x] += k;
}
int query(int x) {
  int k = 0;
  for (; x; x ^= (x & -x)) k += b[x];
  return k;
}
int main() {
  scanf("%d", &n);
  vector<int> arr;
  arr.resize(n);
  for (int i = 0; i < n; i++) scanf("%d", &arr[i]);
  solve(arr, 30);
  int y = 0;
  for (int i = 0; i <= 30; i++)
    if (sum[i] > 0) y ^= (1 << i);
  for (int i = 0; i < n; i++) x[i] = arr[i] ^= y;
  sort(x, x + n);
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    int v = lower_bound(x, x + n, arr[i]) - x + 1;
    ans += i - query(v);
    modify(v, 1);
  }
  printf("%lld %d\n", ans, y);
}
