#include <bits/stdc++.h>
using namespace std;
pair<long long, int> getBit(vector<vector<int>> &gs, int ib) {
  long long ni[2] = {0};
  for (int b = 0; b < 2; b++) {
    for (auto &v : gs) {
      int n1 = 0;
      for (auto &x : v)
        if (((x >> ib) ^ b) & 1)
          n1++;
        else
          ni[b] += n1;
    }
  }
  if (ni[0] <= ni[1])
    return {ni[0], 0};
  else
    return {ni[1], 1};
}
int main() {
  int n;
  while (scanf("%d", &n) == 1) {
    vector<int> a(n);
    for (auto &x : a) cin >> x;
    long long ni = 0;
    int x = 0;
    vector<vector<int>> gs = {a};
    for (int ib = 30; ib >= 0; ib--) {
      auto [tni, b] = getBit(gs, ib);
      x |= b << ib;
      ni += tni;
      vector<vector<int>> ngs;
      for (auto &v : gs) {
        vector<int> b[2];
        for (auto &x : v) b[x >> ib & 1].push_back(x);
        for (int i = 0; i < 2; i++)
          if (!b[i].empty()) ngs.push_back(b[i]);
      }
      gs = ngs;
    }
    printf("%lld %d\n", ni, x);
  }
}
