#include <bits/stdc++.h>
using namespace std;
int64_t reverse_count(const vector<int>& lhs, const vector<int>& rhs) {
  int64_t result = 0;
  for (size_t i = 0; i < lhs.size(); ++i) {
    result += upper_bound(rhs.begin(), rhs.end(), lhs[i]) - rhs.begin();
  }
  return result;
}
vector<vector<int64_t>> zero_one(30, vector<int64_t>(2, 0));
struct TreeNode {
  TreeNode* lhs = nullptr;
  TreeNode* rhs = nullptr;
  vector<int> nums;
  int bit_i = 0;
  void add(int n, int ind, int bit_ind) {
    bit_i = bit_ind;
    nums.push_back(ind);
    if (bit_ind == -1) return;
    if (n & (1 << (bit_ind))) {
      if (!rhs) rhs = new TreeNode();
      rhs->add(n, ind, bit_ind - 1);
    } else {
      if (!lhs) lhs = new TreeNode();
      lhs->add(n, ind, bit_ind - 1);
    }
  }
  void calculate() {
    if (lhs && rhs) {
      int64_t zero_count = reverse_count(lhs->nums, rhs->nums);
      int64_t one_count = reverse_count(rhs->nums, lhs->nums);
      zero_one[bit_i][0] += zero_count;
      zero_one[bit_i][1] += one_count;
    }
    if (lhs) lhs->calculate();
    if (rhs) rhs->calculate();
  }
};
void solve() {
  int n;
  cin >> n;
  TreeNode nums_tree;
  for (size_t i = 0; i < n; ++i) {
    int tmp;
    cin >> tmp;
    nums_tree.add(tmp, i, 29);
  }
  nums_tree.calculate();
  int result = 0;
  int64_t min_c = 0;
  for (size_t i = 0; i < 30; ++i) {
    if (zero_one[i][1] < zero_one[i][0]) {
      result += 1 << i;
    }
    min_c += min(zero_one[i][1], zero_one[i][0]);
  }
  cout << min_c << " " << result;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int t = 1;
  while (t--) solve();
  return 0;
}
