#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const long double PI = acos((long double)-1);
long long cnt[32][2];
class Node {
 public:
  Node* child[2];
  long long cnt;
  Node() {
    child[0] = child[1] = NULL;
    cnt = 0;
  }
};
class Trie {
 private:
  Node* root;

 public:
  Trie() { root = new Node(); }
  void insert(long long no) {
    Node* curr = root;
    for (long long i = 31; i >= 0; --i) {
      long long bit = (no >> i) & 1;
      if (!curr->child[bit]) {
        curr->child[bit] = new Node();
      }
      if (curr->child[0] && curr->child[1]) {
        if (bit) {
          cnt[i][bit] += curr->child[0]->cnt;
        } else {
          cnt[i][bit] += curr->child[1]->cnt;
        }
      }
      curr = curr->child[bit];
      ++curr->cnt;
    }
  }
};
void solve() {
  long long n;
  cin >> n;
  Trie t;
  for (long long i = 1; i <= n; ++i) {
    long long x;
    cin >> x;
    t.insert(x);
  }
  long long x = 0;
  long long inv = 0;
  for (long long i = 31; i >= 0; --i) {
    if (cnt[i][1] < cnt[i][0]) {
      x += (1 << i);
      inv += cnt[i][1];
    } else {
      inv += cnt[i][0];
    }
  }
  cout << inv << " " << x << '\n';
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  solve();
  return 0;
}
