#include <bits/stdc++.h>
using namespace std;
using pii = pair<long long, long long>;
using pil = pair<long long, long long>;
using pli = pair<long long, long long>;
using pll = pair<long long, long long>;
using pdd = pair<long double, long double>;
using vint = vector<long long>;
using vll = vector<long long>;
using vpii = vector<pii>;
using vpil = vector<pil>;
using vpli = vector<pli>;
using vpll = vector<pll>;
const long long N = 3e5 + 5;
const long long Inf = 1e9 + 7;
const long long INF = 1e18 + 7;
const long long Mod = 998244353;
const long double eps = 1e-9;
void io() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
}
long long n;
long long a[N], b[N], c[N];
long long ms(long long l, long long r) {
  long long ans = 0;
  if (r - l < 2) return 0;
  long long m = (l + r) >> 1;
  ans += ms(l, m);
  ans += ms(m, r);
  long long lp = l, rp = m;
  long long ptr = 0;
  while (lp < m && rp < r) {
    if (c[lp] <= c[rp]) {
      b[ptr] = c[lp];
      ans += rp - m;
      ++lp;
      ++ptr;
    } else {
      b[ptr] = c[rp];
      ++ptr;
      ++rp;
    }
  }
  for (; lp < m; ++lp) {
    b[ptr++] = c[lp];
    ans += r - m;
  }
  for (; rp < r; ++rp) b[ptr++] = c[rp];
  for (long long i = l; i < r; ++i) {
    c[i] = b[i - l];
  }
  return ans;
}
long long get_ic(long long x) {
  for (long long i = 0; i < n; ++i) {
    c[i] ^= x;
  }
  return ms(0, n);
}
long long get_icr(long long x) {
  for (long long i = 0; i < n; ++i) {
    c[i] ^= x;
  }
  return ms(0, n);
}
void cp() {
  for (long long i = 0; i < n; ++i) c[i] = a[i];
}
void solve() {
  cin >> n;
  for (long long i = 0; i < n; ++i) cin >> a[i];
  long long ans = 0;
  cp();
  for (long long i = 29; i > -1; --i) {
    long long ic = get_ic(ans);
    cp();
    long long icr = get_icr(ans + (1 << i));
    cp();
    if (icr < ic) ans += (1 << i);
  }
  long long t = get_ic(ans);
  cout << t << ' ' << ans << '\n';
}
signed main() {
  io();
  long long tt = 1;
  while (tt--) {
    solve();
  }
}
