#include <bits/stdc++.h>
using namespace std;
const long long MOD = 2e16;
const int maxn = 4e6 + 100;
const long long linf = 9223372036854775807;
const int inf = 0x3f3f3f3f;
const double eps = 1e-4;
const double DoubleInf = 1e20;
const double pi = acos(-1.0);
long long qpow(long long a, long long b) {
  return b ? ((b & 1) ? a * qpow(a * a % MOD, b >> 1) % MOD
                      : qpow(a * a % MOD, b >> 1)) %
                 MOD
           : 1ll;
}
long long quick_mod(long long a, long long b, long long MOD) {
  long long ans = 1;
  a %= MOD;
  while (b) {
    if (b & 1) {
      ans = ans * a % MOD;
      b--;
    }
    b >>= 1;
    a = a * a % MOD;
  }
  return ans;
}
inline int ird() {
  register int x = 0, f = 1;
  register char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9')
    x = (x << 3) + (x * 2) + ch - '0', ch = getchar();
  return x * f;
}
inline long long lrd() {
  register long long x = 0, f = 1;
  register char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9')
    x = (x << 3) + (x * 2) + ch - '0', ch = getchar();
  return x * f;
}
void puts1() { cout << "-1" << endl; }
void puts2() { cout << "YES" << endl; }
void puts3() { cout << "NO" << endl; }
int gcd(int a, int b) { return (b > 0) ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }
long long lgcd(long long a, long long b) {
  return (b > 0) ? lgcd(b, a % b) : a;
}
long long llcm(long long a, long long b) { return a * b / lgcd(a, b); }
int Trie[maxn][2], tot = 1, a[maxn];
long long dp[maxn][2];
vector<int> mp[maxn];
void insert(int x, int id) {
  int ch, p = 1;
  for (int i = 30; i >= 0; i--) {
    ch = x >> i & 1;
    if (Trie[p][ch] == 0) Trie[p][ch] = ++tot;
    p = Trie[p][ch];
    mp[p].push_back(id);
  }
  return;
}
void dfs(int dep, int node) {
  if (Trie[node][0]) dfs(dep - 1, Trie[node][0]);
  if (Trie[node][1]) dfs(dep - 1, Trie[node][1]);
  if (Trie[node][0] == 0 || Trie[node][1] == 0) return;
  long long sum = 0;
  long long tt = 0;
  for (int i = 0; i < mp[Trie[node][0]].size(); i++) {
    while (tt < mp[Trie[node][1]].size() &&
           mp[Trie[node][1]][tt] < mp[Trie[node][0]][i])
      tt++;
    sum += tt;
  }
  dp[dep][0] += sum;
  dp[dep][1] += (long long)mp[Trie[node][0]].size() *
                    (long long)mp[Trie[node][1]].size() -
                sum;
}
int main() {
  int T, n, x;
  long long ans = 0, u = 0;
  T = 1;
  while (T--) {
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) {
      scanf("%d", &a[i]);
      insert(a[i], i);
    }
    dfs(30, 1);
    for (int i = 0; i <= 30; i++) {
      ans += min(dp[i][0], dp[i][1]);
      if (dp[i][1] < dp[i][0]) u += (1 << i);
    }
    printf("%lld %lld\n", ans, u);
  }
  return 0;
}
