code:
#include<iostream>
using namespace std;
const int N = 3e5 + 5;
typedef long long ll;
int trie[N * 30][2];
int count = 0;
ll sz[N * 30]={0};
ll dp[35][2]={0};
void insert(int x){
int root = 0;
for(int i = 30;i >= 0;i--){
int j =(x>>i)&1;
dp[i][j] += sz[trie[root][j^1]];
if(!trie[root][j])trie[root][j] = ++count;
root = trie[root][j];
sz[root]++;
}
}
int n,ans=0;
ll tot =0;
int main(){
cin>>n;
for(int i = 1;i <= n;i++){
int x;
cin>>x;
insert(x);
}
for(int i = 30;i >= 0;i--){
if(dp[i][0] > dp[i][1]){
ans |= (1<<i);
tot += dp[i][1];
}else tot += dp[i][0];
}
cout<<tot<<" "<<ans;
return 0;
}