#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 111;
const int BITS = 29;
int n;
int A[N];
long long DP[2][BITS + 1];
class Node {
 public:
  Node* next[2];
  vector<int> poses;
  int height;
  Node() {
    next[0] = next[1] = NULL;
    poses.clear();
    height = BITS;
  }
  ~Node() {
    if (next[0] != NULL) delete next[0];
    if (next[1] != NULL) delete next[1];
  }
  void Push(int pos) { poses.push_back(pos); }
};
class Trie {
 public:
  Node* root;
  Trie() { root = new Node(); }
  ~Trie() { delete root; }
  void Insert(int x, int pos) {
    Node* p = root;
    for (int i = BITS; i >= 0; --i) {
      int b = ((x >> i) & 1);
      if (p->next[b] == NULL) {
        p->next[b] = new Node();
        p->next[b]->height = p->height - 1;
      }
      p = p->next[b];
      p->Push(pos);
    }
  }
  void DFS() { DFS(root); }
  void DFS(Node* node) {
    if (node == NULL) return;
    Node* l = node->next[0];
    Node* r = node->next[1];
    DFS(node->next[0]);
    DFS(node->next[1]);
    if (l == NULL || r == NULL) return;
    int pnt = 0;
    long long res = 0;
    for (auto x : l->poses) {
      while (pnt < (int)r->poses.size() && r->poses[pnt] < x) ++pnt;
      res += pnt;
    }
    DP[0][node->height] += res;
    DP[1][node->height] += l->poses.size() * 1LL * r->poses.size() - res;
  }
} T;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> A[i];
    T.Insert(A[i], i);
  }
  T.DFS();
  long long nInv = 0;
  int res = 0;
  for (int i = 0; i <= BITS; ++i) {
    if (DP[0][i] <= DP[1][i]) {
      nInv += DP[0][i];
    } else {
      nInv += DP[1][i];
      res |= (1 << i);
    }
  }
  cout << nInv << ' ' << res << '\n';
}
