#include <bits/stdc++.h>
using namespace std;
long long dp[2][30];
void go(vector<int> s, int pos) {
  if (s.size() == 0) return;
  if (pos == -1) return;
  long long ones = 0;
  long long zeroes = 0;
  long long oneinv = 0;
  long long zeroinv = 0;
  vector<int> l, r;
  for (auto &x : s) {
    if ((x >> pos) & 1) {
      ones++;
      oneinv += zeroes;
      r.push_back(x);
    } else {
      zeroes++;
      zeroinv += ones;
      l.push_back(x);
    }
  }
  dp[1][pos] += oneinv;
  dp[0][pos] += zeroinv;
  go(l, pos - 1);
  go(r, pos - 1);
}
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < 30; i++) {
    dp[0][i] = 0;
    dp[1][i] = 0;
  }
  for (auto &x : a) cin >> x;
  go(a, 29);
  long long ans = 0;
  int x = 0;
  for (int i = 0; i < 30; i++) {
    if (dp[1][i] < dp[0][i]) {
      ans += dp[1][i];
      x |= 1 << i;
    } else {
      ans += dp[0][i];
    }
  }
  cout << ans << " " << x << endl;
}
