#include <bits/stdc++.h>
using namespace std;
long long ans = 0;
pair<long long, long long> wtf[30];
void recurr(int h, vector<int> V) {
  vector<int> V1, V2;
  int cnt = 0;
  for (int i = 0; i < V.size(); ++i) {
    if ((V[i] >> h) & 1) {
      wtf[h].first += i - cnt;
      ++cnt;
      V1.push_back(V[i]);
    } else
      V2.push_back(V[i]);
  }
  cnt = 0;
  for (int i = V.size() - 1; i >= 0; --i) {
    if ((V[i] >> h) & 1) {
      wtf[h].second += (V.size() - 1 - i) - cnt;
      ++cnt;
    }
  }
  if (h > 0) {
    if (!V1.empty()) recurr(h - 1, V1);
    if (!V2.empty()) recurr(h - 1, V2);
  }
}
int main() {
  long long n, x = 0;
  cin >> n;
  vector<int> V;
  for (int i = 0; i < n; ++i) {
    int a;
    cin >> a;
    V.push_back(a);
  }
  for (int i = 0; i < 30; ++i) {
    wtf[i] = {0, 0};
  }
  recurr(29, V);
  for (int i = 0; i < 30; ++i) {
    ans += min(wtf[i].first, wtf[i].second);
    if (wtf[i].first < wtf[i].second) {
      x += (1 << i);
    }
  }
  cout << ans << ' ' << x << '\n';
}
