#include <bits/stdc++.h>
#pragma GCC optimize(2)
#pragma GCC optimize(3)
using namespace std;
template <typename T1, typename T2>
void ckmin(T1 &a, T2 b) {
  if (a > b) a = b;
}
template <typename T1, typename T2>
void ckmax(T1 &a, T2 b) {
  if (a < b) a = b;
}
template <typename T>
T gcd(T a, T b) {
  return b ? gcd(b, a % b) : a;
}
int read() {
  int x = 0, f = 0;
  char ch = getchar();
  while (!isdigit(ch)) f |= ch == '-', ch = getchar();
  while (isdigit(ch)) x = 10 * x + ch - '0', ch = getchar();
  return f ? -x : x;
}
const int N = 300005;
vector<int> a;
long long dp[35][2];
int n;
void solve(vector<int> a, int bit) {
  if (bit == -1 || a.size() == 0) return;
  vector<int> low, high;
  int cnt0 = 0, cnt1 = 0;
  for (auto v : a) {
    if (v >> bit & 1) {
      dp[bit][1] += cnt0;
      cnt1++;
      high.push_back(v);
    } else {
      dp[bit][0] += cnt1;
      cnt0++;
      low.push_back(v);
    }
  }
  solve(low, bit - 1), solve(high, bit - 1);
}
int main() {
  n = read();
  for (register int i = 1; i <= n; i++) a.push_back(read());
  solve(a, 30);
  long long ans = 0, num = 0;
  for (register int i = 30; i >= 0; i--) {
    if (dp[i][0] <= dp[i][1]) {
      ans += dp[i][0];
    } else {
      ans += dp[i][1];
      num ^= 1ll << i;
    }
  }
  printf("%lld %lld\n", ans, num);
}
