constint N = (3e5 + 9) * 30; int n, x, a[N], tr[N][2], tot; longlong inv[33], dir[33], s[N];
voidinsert(constint &x){ int u = 0; for (int i = 31; i + 1; i--) { int c = ((x >> i) & 1); if (!tr[u][c]) tr[u][c] = ++tot; u = tr[u][c]; s[u]++; } } voidqry(constint &x){ int u = 0; for (int i = 31; i + 1; i--) { int c = ((x >> i) & 1); if (c == 0) inv[i] += s[tr[u][1]]; if (c == 1) dir[i] += s[tr[u][0]]; u = tr[u][c]; } }
intmain(){ scanf("%d", &n); for (int i = 1; i <= n; i++) scanf("%d", &a[i]), insert(a[i]), qry(a[i]); longlong res = 0; int x = 0; for (int i = 0; i <= 31; i++) { if (inv[i] > dir[i]) x |= (1 << i), res += dir[i]; else res += inv[i]; } printf("%lld %d\n", res, x); return0; }