#include <bits/stdc++.h>
using namespace std;
const long long N = 300005;
long long bit[N], a[N], b[N], mem[N];
pair<long long, long long> d[N];
long long n;
void update(long long i, long long v, long long n) {
  for (; i <= n; i += i & -i) {
    bit[i] += v;
  }
}
long long get(long long i) {
  long long v = 0;
  for (; i; i -= i & -i) {
    v += bit[i];
  }
  return v;
}
long long invc(long long a[]) {
  memset(bit, 0, sizeof(bit));
  long long ret = 0;
  for (long long i = 0; i < n; i++) {
    d[i] = pair<long long, long long>(a[i], i);
  }
  sort(d, d + n);
  long long c = 1;
  for (long long i = 0; i < n; i++) {
    if (i && d[i].first != d[i - 1].first) c++;
    mem[d[i].second] = c;
  }
  for (long long i = n - 1; i >= 0; i--) {
    ret += get(mem[i]);
    update(mem[i] + 1, 1, c);
  }
  return ret;
}
void Main() {
  cin >> n;
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
  }
  long long ans = 0, t = invc(a);
  for (long long j = 29; j >= 0; j--) {
    for (long long i = 0; i < n; i++) {
      b[i] = a[i] ^ (1 << j);
    }
    long long g = invc(b);
    if (g < t) {
      t = g;
      ans ^= (1 << j);
      for (long long k = 0; k < n; k++) {
        a[k] ^= (1 << j);
      }
    }
  }
  cout << t << ' ' << ans << '\n';
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  long long T = 1;
  while (T--) Main();
}
