#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
template <typename T>
void _dbg(char const *s, const T &t) {
  cerr << s << "=" << t << endl;
}
template <typename T, typename... TA>
void _dbg(char const *s, const T &t, const TA &...ta) {
  while (*s != ',') cerr << *s++;
  cerr << "=" << t << ",";
  _dbg(s + 1, ta...);
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) {
  return os << "(" << p.first << "," << p.second << ")";
}
template <typename T>
ostream &print_iterable(ostream &os, T beg, T end) {
  os << '[';
  for (auto it = beg; it != end; ++it) {
    if (it != beg) os << ", ";
    os << *it;
  }
  return os << ']';
}
template <typename T, size_t N>
ostream &operator<<(ostream &os, const array<T, N> &x) {
  return print_iterable(os, x.begin(), x.end());
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &x) {
  return print_iterable(os, x.begin(), x.end());
}
template <typename T>
ostream &operator<<(ostream &os, const set<T> &x) {
  return print_iterable(os, x.begin(), x.end());
}
template <typename T>
ostream &operator<<(ostream &os, const multiset<T> &x) {
  return print_iterable(os, x.begin(), x.end());
}
template <typename T>
ostream &operator<<(ostream &os, const unordered_set<T> &x) {
  return print_iterable(os, x.begin(), x.end());
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, const map<T1, T2> &x) {
  return print_iterable(os, x.begin(), x.end());
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, const unordered_map<T1, T2> &x) {
  return print_iterable(os, x.begin(), x.end());
}
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pdd = pair<ld, ld>;
void solve() {
  int n;
  cin >> n;
  vector<int> as(n);
  for (auto &a : as) {
    cin >> a;
  };
  int xorx = 0;
  long long tot_inv = 0;
  vector<vector<int>> groups = {as};
  vector<vector<int>> ngroups;
  for (int bit = 30; bit >= 0; --bit) {
    ;
    long long inv = 0;
    long long alt = 0;
    for (const auto &g : groups) {
      int cnt_0 = 0;
      int cnt_1 = 0;
      vector<int> ngroup[2];
      for (int x : g) {
        bool isbit = (x >> bit) & 1;
        if (isbit) {
          alt += cnt_0;
          cnt_1 += 1;
        } else {
          inv += cnt_1;
          cnt_0 += 1;
        }
        if (isbit) x ^= 1 << bit;
        ngroup[isbit].push_back(x);
      }
      if (!ngroup[0].empty()) ngroups.push_back(std::move(ngroup[0]));
      if (!ngroup[1].empty()) ngroups.push_back(std::move(ngroup[1]));
    };
    if (alt < inv) {
      xorx ^= (1 << bit);
    }
    tot_inv += min(inv, alt);
    swap(groups, ngroups);
    ngroups.clear();
  }
  cout << tot_inv << " " << xorx << endl;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  solve();
  return 0;
}
