#include <bits/stdc++.h>
using namespace std;
long long int add(long long int x, long long int y) {
  return (x % 1000000007 + y % 1000000007) % 1000000007;
}
long long int mul(long long int x, long long int y) {
  return ((x % 1000000007) * (y % 1000000007)) % 1000000007;
}
long long int sub(long long int x, long long int y) {
  return (x - y + 1000000007) % 1000000007;
}
void solve() {
  long long int n, i, j, ans1 = 0, ans2 = 0;
  cin >> n;
  long long int a[n];
  long long int s[n];
  unordered_map<long long int, vector<long long int>> m;
  for (long long int i = 0; i < n; i++) {
    cin >> a[i];
    s[i] = 0;
  }
  for (long long int i = 31; i >= 0; i--) {
    m.clear();
    for (long long int j = 0; j < n; j++) {
      if (1 << i & a[j]) {
        m[s[j]].push_back(1);
        s[j] = 2 * s[j] + 1;
      } else {
        m[s[j]].push_back(0);
        s[j] = 2 * s[j] + 0;
      }
    }
    long long int e = 0, f = 0;
    for (auto v : m) {
      long long int c = 0, d = 0;
      for (auto k : v.second) {
        if (k == 1) {
          c++;
          f += d;
        } else {
          d++;
          e += c;
        }
      }
    }
    if (e > f) {
      ans2 += (1 << i);
    }
    ans1 += min(e, f);
  }
  cout << ans1 << " " << ans2;
  cout << '\n';
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int TESTS = 1;
  while (TESTS--) {
    solve();
  }
  return 0;
}
