#include <bits/stdc++.h>
const long long INF = 0x3f3f3f3f3f3f3f3fLL;
const int inf = 0x3f3f3f3f;
const int mod = 998244353;
const double eps = 1e-6;
template <typename T>
void read(T &x) {
  x = 0;
  char ch = getchar();
  long long f = 1;
  while (!isdigit(ch)) {
    if (ch == '-') f *= -1;
    ch = getchar();
  }
  while (isdigit(ch)) {
    x = x * 10 + ch - 48;
    ch = getchar();
  }
  x *= f;
}
template <typename T, typename... Args>
void read(T &first, Args &...args) {
  read(first);
  read(args...);
}
using namespace std;
const int maxn = 3e5 + 10;
int a[maxn];
vector<int> ee[maxn], aa[maxn];
int main() {
  int n;
  read(n);
  for (int i = 1; i <= n; ++i) {
    read(a[i]);
    ee[1].emplace_back(a[i]);
  }
  long long tot = 1, sum = 0, ans = 0;
  auto calc = [&](vector<int> &ve, int x, bool ojbk) {
    long long cnt = 0, ans = 0;
    for (auto it : ve) {
      if (ojbk) it ^= x;
      if ((it | x) == it) {
        ++cnt;
      } else {
        ans += cnt;
      }
    }
    return ans;
  };
  for (int i = 31; i >= 0; --i) {
    long long ans1 = 0, ans2 = 0;
    for (int j = 1; j <= tot; ++j) {
      ans1 += calc(ee[j], 1 << i, 0);
      ans2 += calc(ee[j], 1 << i, 1);
    }
    int cur = 0, k = 0;
    if (ans1 > ans2) {
      k = 1 << i;
      ans += k;
      sum += ans2;
    } else {
      sum += ans1;
    }
    int cc[2] = {0};
    for (int j = 1; j <= tot; ++j) {
      cc[0] = cc[1] = 0;
      for (auto it : ee[j]) {
        int y = (it | (1 << i));
        if (cc[y == it] == 0) cc[y == it] = ++cur;
        aa[cc[y == it]].emplace_back(it ^ k);
      }
    }
    for (int i = 1; i <= cur; ++i) {
      ee[i].clear();
      ee[i].swap(aa[i]);
    }
    tot = cur;
  }
  printf("%lld %lld\n", sum, ans);
}
