#include <bits/stdc++.h>
using namespace std;
void see(int x) { cout << x; }
void see(long long int x) { cout << x; }
void see(long double x) { cout << x; }
void see(char x) { cout << '\'' << x << '\''; }
void see(string x) { cout << '\"' << x << '\"'; }
template <typename T, typename V>
void see(const pair<T, V> &x) {
  cout << '{';
  see(x.first);
  cout << ',';
  see(x.second);
  cout << '}';
}
template <typename T>
void see(const T &x) {
  int f = 0;
  cout << '{';
  for (auto &i : x) cout << (f++ ? "," : ""), see(i);
  cout << "}";
}
void _print() { cout << "]\n"; }
template <typename T, typename... V>
void _print(T t, V... v) {
  see(t);
  if (sizeof...(v)) cout << ", ";
  _print(v...);
}
long long int gcd(long long int a, long long int b) {
  return (!b) ? a : gcd(b, a % b);
}
const int N = 30 * 3e5 + 5;
int val[N];
int trie[N][2];
long long int dp[32][2], cur;
void add(int x) {
  int st = 0;
  for (int i = 31; i >= 0; i--) {
    int bt = ((x >> i) & 1);
    if (!trie[st][bt]) trie[st][bt] = ++cur;
    dp[i][bt] += val[trie[st][!bt]];
    st = trie[st][bt];
    val[st] += 1;
  }
}
void solve() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    int x;
    cin >> x;
    add(x);
  }
  long long int inv = 0;
  int ans = 0;
  for (int i = 0; i <= 31; i++) {
    if (dp[i][1] < dp[i][0]) {
      inv += 1ll * dp[i][1];
      ans += (1 << i);
    } else {
      inv += 1ll * dp[i][0];
    }
  }
  cout << inv << " " << ans << '\n';
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  solve();
}
