#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const double eps = 1e-8;
const int maxN = 5e6 + 5;
const int N = 30;
inline long long read() {
  long long ans = 0;
  char ch = getchar(), las = ' ';
  while (!isdigit(ch)) las = ch, ch = getchar();
  while (isdigit(ch)) ans = (ans << 1) + (ans << 3) + ch - '0', ch = getchar();
  if (las == '-') ans = -ans;
  return ans;
}
inline void write(long long x) {
  if (x < 0) x = -x, putchar('-');
  if (x >= 10) write(x / 10);
  putchar(x % 10 + '0');
}
inline void MYFILE() {
  freopen(".in", "r", stdin);
  freopen(".out", "w", stdout);
}
int n;
long long dp[N + 2][2];
struct Trie {
  int ch[maxN][2], tot;
  vector<int> v[maxN];
  Trie() {
    memset(ch, 0, sizeof(ch));
    tot = 1;
  }
  inline void insert(int x, int pos) {
    int now = 1;
    for (int i = N; i >= 0; --i) {
      int p = (x >> i) & 1;
      if (!ch[now][p]) ch[now][p] = ++tot, v[tot].clear();
      now = ch[now][p], v[now].push_back(pos);
    }
  }
  inline void dfs(int now, int h) {
    if (!now) return;
    int ls = ch[now][0], rs = ch[now][1];
    int cnt1 = v[ls].size(), cnt2 = v[rs].size();
    long long sum = 0;
    for (int i = 0, j = 0; i < cnt1; ++i) {
      while (j < cnt2 && v[ls][i] > v[rs][j]) ++j;
      sum += j;
    }
    dp[h][0] += sum;
    dp[h][1] += 1LL * cnt1 * cnt2 - sum;
    dfs(ls, h - 1), dfs(rs, h - 1);
  }
} tr;
int main() {
  n = read();
  for (int i = 1; i <= n; ++i) {
    int x = read();
    tr.insert(x, i);
  }
  tr.dfs(1, N + 1);
  long long ans = 0, x = 0;
  for (int i = N; i >= 0; --i) {
    ans += min(dp[i][0], dp[i][1]);
    if (dp[i][1] < dp[i][0]) x |= (1 << (i - 1));
  }
  write(ans), putchar(' '), write(x), puts("");
  return 0;
}
