#include <bits/stdc++.h>
using namespace std;
long long int modinverse(long long int x, long long int y) {
  if (y == 0) {
    return 1;
  }
  long long int p = modinverse(x, y / 2) % 1000000007;
  p = (p * p) % 1000000007;
  return (y % 2 == 0) ? p : (x * p) % 1000000007;
}
long long int modexp(long long int a, long long int n) {
  long long int ans = 1;
  a = a % 1000000007;
  while (n > 0) {
    if (n % 2) {
      ans = (ans * a) % 1000000007;
    }
    n /= 2;
    a = (a * a) % 1000000007;
  }
  return ans;
}
long long int arr[300001], on[30], off[30];
void solve(vector<long long int> index, long long int k) {
  if (k == -1 or index.size() <= 1) {
    return;
  }
  vector<long long int> one, zero;
  long long int cnt1 = 0, cnt2 = 0, inversion1 = 0, inversion2 = 0;
  for (auto itr : index) {
    if ((arr[itr] >> k) % 2 == 1) {
      one.push_back(itr);
      cnt1++;
      inversion1 += cnt2;
    } else {
      zero.push_back(itr);
      cnt2++;
      inversion2 += cnt1;
    }
  }
  on[k] += inversion1;
  off[k] += inversion2;
  solve(zero, k - 1);
  solve(one, k - 1);
}
long long int countInversion(vector<long long int> index, long long int k) {
  if (k == -1 or index.size() <= 1) {
    return 0;
  }
  vector<long long int> zero, one;
  long long int cnt = 0, inversion = 0;
  for (auto itr : index) {
    if ((arr[itr] >> k) % 2 == 1) {
      one.push_back(itr);
      cnt++;
    } else {
      zero.push_back(itr);
      inversion += cnt;
    }
  }
  inversion += countInversion(zero, k - 1);
  inversion += countInversion(one, k - 1);
  return inversion;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int tt = 1;
  for (long long int tc = 1; tc <= tt; tc++) {
    long long int n;
    cin >> n;
    for (long long int i = 0; i <= n - 1; i++) {
      cin >> arr[i];
    }
    vector<long long int> v;
    for (long long int i = 0; i <= n - 1; i++) {
      v.push_back(i);
    }
    for (long long int i = 0; i <= 29; i++) {
      on[i] = off[i] = 0;
    }
    solve(v, 29);
    long long int x = 0;
    for (long long int i = 0; i <= 29; i++) {
      if (on[i] < off[i]) {
        x += pow(2, i);
      }
    }
    for (long long int i = 0; i <= n - 1; i++) {
      arr[i] = (arr[i] ^ x);
    }
    long long int b = countInversion(v, 29);
    cout << b << " " << x;
    cout << '\n';
  }
  return 0;
}
