#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  long long x = 0, f = 1;
  char c = getchar();
  while (!isdigit(c)) {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (isdigit(c)) {
    x = (x << 1) + (x << 3) + (c ^ 48);
    c = getchar();
  }
  return f == 1 ? x : -x;
}
const long long N = 3e5 + 4;
long long n, cur, Ans, cou, a[N], b[N], a1[N], a2[N];
vector<long long> duan[2];
inline long long solve(long long l, long long r) {
  long long ret = 0;
  for (long long i = l, t1 = 0; i <= r; i++) {
    if (b[i])
      t1++;
    else
      ret += t1;
  }
  return ret;
}
inline void split(long long l, long long r) {
  a1[0] = a2[0] = 0;
  for (long long i = l; i <= r; i++) {
    if (b[i])
      a2[++a2[0]] = a[i];
    else
      a1[++a1[0]] = a[i];
  }
  for (long long i = 1; i <= a1[0]; i++) a[i + l - 1] = a1[i];
  for (long long i = 1; i <= a2[0]; i++) a[i + l + a1[0] - 1] = a2[i];
  if (a1[0]) duan[cur].push_back(l + a1[0] - 1);
  if (a2[0]) duan[cur].push_back(r);
}
signed main() {
  n = read();
  for (long long i = 1; i <= n; i++) a[i] = read();
  duan[cur].push_back(n);
  for (long long t = 30, pre, ans0, ans1; t >= 0; t--) {
    for (long long i = 1; i <= n; i++) b[i] = (a[i] >> t) & 1;
    cur ^= 1;
    duan[cur].clear();
    pre = ans0 = 0;
    for (auto v : duan[cur ^ 1]) {
      ans0 += solve(pre + 1, v);
      pre = v;
    }
    for (long long i = 1; i <= n; i++) b[i] = b[i] ^ 1;
    pre = ans1 = 0;
    for (auto v : duan[cur ^ 1]) {
      ans1 += solve(pre + 1, v);
      pre = v;
    }
    if (ans0 <= ans1) {
      cou += ans0;
    } else {
      cou += ans1;
      Ans |= (1 << t);
    }
    pre = 0;
    for (auto v : duan[cur ^ 1]) {
      split(pre + 1, v);
      pre = v;
    }
  }
  cout << cou << " " << Ans << "\n";
  return (0 - 0);
}
