#include <bits/stdc++.h>
using namespace std;
bool isprime(long long n) {
  if (n <= 1) return false;
  if (n <= 3) return true;
  if (n % 2 == 0 || n % 3 == 0) return false;
  for (long long i = 5; i * i <= n; i += 6) {
    if (n % i == 0 || n % (i + 2) == 0) return false;
  }
  return true;
}
long long modexp(long long a, long long b, long long m) {
  long long r = 1;
  a = a % m;
  while (b > 0) {
    if (b & 1) r = (r * a) % m;
    b = b >> 1;
    a = (a * a) % m;
  }
  return r % m;
}
long long builtin_popcount(long long x) {
  long long cnt = 0;
  for (long long i = 60; i >= 0; i--) {
    if ((1LL << i) & x) cnt++;
  }
  return cnt;
}
long long addmod(long long a, long long b) {
  a %= 998244353;
  b %= 998244353;
  return (a + b) % 998244353;
}
long long mulmod(long long a, long long b) {
  a %= 998244353;
  b %= 998244353;
  return (a * b) % 998244353;
}
long long submod(long long a, long long b) {
  a %= 998244353;
  b %= 998244353;
  a -= b;
  if (a < 0) a += 998244353;
  return a % 998244353;
}
struct CustomCompare {
  bool operator()(long long a, long long b) { return a > b; }
};
const int mxn = 5e6 + 10;
long long n, nxt = 1;
vector<long long> g[mxn];
long long dp[mxn][2], trie[mxn][2];
void add(long long val, long long pos) {
  long long curr = 0;
  for (long long bit = 29; bit >= 0; bit--) {
    long long check = ((val >> bit) & 1LL);
    if (!trie[curr][check]) trie[curr][check] = nxt++;
    curr = trie[curr][check];
    g[curr].push_back(pos);
  }
}
void solve(long long curr, long long bit) {
  long long l = trie[curr][0], r = trie[curr][1];
  if (l) solve(l, bit - 1);
  if (r) solve(r, bit - 1);
  if (!l || !r) return;
  long long res = 0, pos = 0;
  for (auto x : g[l]) {
    while (pos < g[r].size() && g[r][pos] < x) pos++;
    res += pos;
  }
  dp[bit][0] += res;
  dp[bit][1] += (g[l].size() * 1LL * g[r].size() - res);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 0; i < n; i++) {
    long long x;
    cin >> x;
    add(x, i);
  }
  solve(0LL, 29LL);
  long long inv = 0, ans = 0;
  for (int bit = 0; bit < 30; bit++) {
    inv += min(dp[bit][0], dp[bit][1]);
    if (dp[bit][0] > dp[bit][1]) ans += (1LL << bit);
  }
  cout << inv << " " << ans << "\n";
  return 0;
}
