#include <bits/stdc++.h>
using namespace std;
int a[300000];
struct tri {
  tri* next[2];
  bool last;
  vector<int> ids;
  tri() : last(false) { next[0] = next[1] = NULL; }
};
tri* root;
void construct(tri* root, int id, int depth) {
  if (depth < 0) return;
  int bit = !!(a[id] & (1 << depth));
  if (root->next[bit] == NULL) root->next[bit] = new tri();
  root->next[bit]->ids.push_back(id);
  construct(root->next[bit], id, depth - 1);
}
long long int dp[31][2];
void solve(tri* root, int depth) {
  if (root->next[0] == NULL and root->next[1] == NULL) return;
  if (root->next[0] == NULL or root->next[1] == NULL)
    return root->next[0] == NULL ? solve(root->next[1], depth - 1)
                                 : solve(root->next[0], depth - 1);
  vector<int> los = root->next[0]->ids, his = root->next[1]->ids;
  for (int id : los) {
    int inv = lower_bound(his.begin(), his.end(), id) - his.begin();
    dp[depth][0] += inv;
    dp[depth][1] += his.size() - inv;
  }
  solve(root->next[0], depth - 1);
  solve(root->next[1], depth - 1);
}
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  root = new tri();
  for (int id = 0; id < n; id++) construct(root, id, 30);
  solve(root, 30);
  long long int ans = 0LL;
  int x = 0;
  for (int i = 0; i < 31; i++) {
    ans += min(dp[i][1], dp[i][0]);
    if (dp[i][1] < dp[i][0]) x += 1 << i;
  }
  cout << ans << " " << x << "\n";
}
