#include <bits/stdc++.h>
using namespace std;
long long x = 1073741824;
long long now = 1;
long long und[31][2], s[10000000], g[10000000][2];
void add(long long y) {
  long long v = 0;
  for (int i = 30; i >= 0; i--) {
    long long bit = (y >> i) % 2;
    if (g[v][bit] == 0) {
      now++;
      g[v][bit] = now;
    }
    if (bit == 1)
      und[i][0] += s[g[v][0]];
    else
      und[i][1] += s[g[v][1]];
    v = g[v][bit];
    s[v]++;
  }
}
int main() {
  ios::sync_with_stdio(0);
  long long n;
  cin >> n;
  vector<long long> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < n; i++) add(a[i]);
  long long ans = 0, y = 0;
  for (int i = 30; i >= 0; i--) {
    if (und[i][0] < und[i][1]) ans += 1 << i;
    y += min(und[i][0], und[i][1]);
  }
  cout << y << ' ' << ans << "\n";
}
