#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n;
  cin >> n;
  vector<long long> a(n);
  for (long long i = 0; i < n; i++) cin >> a[i];
  long long ans = 0, ans2 = 0;
  vector<vector<long long>> tmp = {a};
  for (long long j = 30; j >= 0; j--) {
    vector<vector<long long>> tmp2;
    long long c = 0, c2 = 0;
    for (auto a : tmp) {
      vector<long long> X, Y;
      long long v = 0, v2 = 0;
      for (auto x : a) {
        if ((x & (1 << j))) {
          c2 += v;
          v2++;
          X.push_back(x);
        } else {
          c += v2;
          v++;
          Y.push_back(x);
        }
      }
      if (X.size() > 0) tmp2.push_back(X);
      if (Y.size() > 0) tmp2.push_back(Y);
    }
    ans += min(c, c2);
    if (c2 < c) ans2 += (1 << j);
    tmp = tmp2;
  }
  cout << ans << " " << ans2;
}
