#include <bits/stdc++.h>
using namespace std;
template <typename Tp>
inline void read(Tp &x) {
  static char c;
  static bool neg;
  x = 0, c = getchar(), neg = false;
  for (; !isdigit(c); c = getchar()) {
    if (c == '-') {
      neg = true;
    }
  }
  for (; isdigit(c); c = getchar()) {
    x = x * 10 + c - '0';
  }
  if (neg) {
    x = -x;
  }
}
const int N = 3e5 + 5;
int n;
int a[N];
struct Set {
  vector<int> fir;
  vector<int> sec;
  inline void push(int len, int x) {
    for (int i = 1, t = (1 << x); i <= len; ++i) {
      if (a[i] & t) {
        fir.emplace_back(i);
      } else {
        sec.emplace_back(i);
      }
    }
  }
  inline void push(const vector<int> &vec, int x) {
    int t = (1 << x);
    for (const auto &v : vec) {
      if (a[v] & t) {
        fir.emplace_back(v);
      } else {
        sec.emplace_back(v);
      }
    }
  }
};
const int MX = 30;
vector<Set> vec[MX];
int main() {
  read(n);
  for (int i = 1; i <= n; ++i) {
    read(a[i]);
  }
  vec[MX - 1].emplace_back(Set());
  vec[MX - 1].back().push(n, MX - 1);
  long long x = 0, cnt = 0, ans0, ans1;
  for (int i = MX - 1; i >= 0; --i) {
    ans0 = ans1 = 0LL;
    for (const auto &x : vec[i]) {
      auto fir = &x.fir, sec = &x.sec;
      size_t pos = 0UL;
      for (size_t now = 0UL; now < fir->size(); ++now) {
        while (pos < sec->size() &&
               sec->operator[](pos) <= fir->operator[](now)) {
          ++pos;
        }
        ans0 += sec->size() - pos;
        ans1 += pos;
      }
      if (i > 0) {
        if (!fir->empty()) {
          vec[i - 1].emplace_back(Set());
          vec[i - 1].back().push(*fir, i - 1);
        }
        if (!sec->empty()) {
          vec[i - 1].emplace_back(Set());
          vec[i - 1].back().push(*sec, i - 1);
        }
      }
    }
    if (ans0 > ans1) {
      x |= (1 << i);
      cnt += ans1;
    } else {
      cnt += ans0;
    }
  }
  printf("%lld %lld\n", cnt, x);
}
