#include <bits/stdc++.h>
using namespace std;
const long long N = 3e6 + 1, M = 2e2 + 1, INF = 2e9, MOD = 1e9 + 7, L = 20,
                NN = 1e9 + 1;
long long mas[N];
long long col[N];
long long k0[N];
long long k1[N];
bool used[N];
long long nextcol[N];
long long fre = 2;
void solve() {
  long long n;
  cin >> n;
  for (long long i = 0; i < n; i++) {
    cin >> mas[i];
    col[i] = 1;
  }
  long long inv = 0;
  long long ans = 0;
  for (long long bit = 40; bit >= 0; bit--) {
    long long inv0 = 0, inv1 = 0;
    for (long long i = 0; i < n; i++) {
      if ((mas[i] & (1LL << bit)) == 0) {
        inv0 += k1[col[i]];
        k0[col[i]]++;
      } else {
        inv1 += k0[col[i]];
        k1[col[i]]++;
        if (used[col[i]]) {
          col[i] = nextcol[col[i]];
        } else {
          used[col[i]] = 1;
          nextcol[col[i]] = fre;
          col[i] = fre;
          fre++;
        }
      }
    }
    for (long long i = 0; i < fre; i++) {
      used[i] = 0;
      k0[i] = 0;
      k1[i] = 0;
    }
    if (inv0 <= inv1) {
      inv += inv0;
    } else {
      inv += inv1;
      ans += (1 << bit);
    }
  }
  cout << inv << ' ' << ans << '\n';
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long t = 1;
  while (t--) solve();
}
