#include <bits/stdc++.h>
const int maxn = 3e5 + 7, maxm = 1e7 + 10;
using namespace std;
int maxs = 0, k, tot = 0;
int t[35][maxn], sum[maxm][2];
long long sumsum = 0, ans = 0;
int b[maxm], a[maxn];
int main() {
  int tot1 = 0;
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    maxs = max(maxs, a[i]);
  }
  k = 33;
  for (int i = k; i >= 0; i--) {
    long long sum0 = 0, sum1 = 0;
    for (int j = 0; j <= tot; j++) sum[j][0] = sum[j][1] = b[j] = 0;
    long long v = 1LL << i;
    for (int j = n; j >= 1; j--) {
      long long num = (v & a[j]);
      if (num) {
        if (!b[t[i + 1][j]]) {
          b[t[i + 1][j]] = ++tot;
          t[i][j] = tot;
        } else
          t[i][j] = b[t[i + 1][j]];
        sum0 += sum[t[i + 1][j]][0];
        sum[t[i + 1][j]][1]++;
      } else {
        t[i][j] = t[i + 1][j];
        sum1 += sum[t[i + 1][j]][1];
        sum[t[i + 1][j]][0]++;
      }
    }
    if (sum0 <= sum1) {
      sumsum += sum0;
    } else {
      sumsum += sum1;
      ans += v;
    }
  }
  cout << sumsum << " " << ans << endl;
  return 0;
}
