#include <bits/stdc++.h>
using namespace std;
const int MAXN = 3e5 + 5;
int n, a[MAXN];
pair<int, int> b[MAXN];
vector<pair<int, int> > inv[100];
int getBit(int x, int i) { return ((x & (1 << i)) > 0); }
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &a[i]);
    b[i].first = a[i];
    b[i].second = i;
  }
  a[n] = -1;
  sort(b, b + n);
  int mask = (1 << 31);
  for (int w = 30; w >= 0; --w) {
    int prev = 0;
    for (int i = 1; i <= n; ++i) {
      if (((b[i].first & mask) != (b[i - 1].first & mask))) {
        inv[w].push_back(pair<int, int>(prev, i - 1));
        prev = i;
      }
    }
    if (inv[w].empty()) inv[w].push_back(pair<int, int>(0, n - 1));
    mask += (1 << w);
  }
  int x = 0;
  long long totInversion = 0;
  for (int w = 0; w <= 30; ++w) {
    long long costRemain = 0, costChanged = 0;
    for (pair<int, int> i : inv[w]) {
      int num0 = 0, num1 = 0;
      vector<int> tmp;
      for (int j = i.first; j <= i.second; ++j) {
        tmp.push_back(b[j].second);
      }
      sort(tmp.begin(), tmp.end());
      for (int j : tmp) {
        int idx = j;
        if (getBit(a[idx], w) == 0) {
          costRemain += num1;
          num0++;
        } else {
          costChanged += num0;
          num1++;
        }
      }
    }
    if (costRemain > costChanged) {
      x += (1 << w);
      totInversion += costChanged;
    } else {
      totInversion += costRemain;
    }
  }
  printf("%lld %d\n", totInversion, x);
}
