#include<bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define Fo(i,n) for(int i=0;i<n;i++)
#define fo(i,k,n) for(int i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long
#define si(x) scanf("%d",&x)
#define sl(x) scanf("%lld",&x)
#define ss(s) scanf("%s",s)
#define pi(x) printf("%d\n",x)
#define pl(x) printf("%lld\n",x)
#define ps(s) printf("%s\n",s)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
typedef pair<int, int>  pii;
typedef pair<ll, ll>  pl;
typedef vector<int>   vi;
typedef vector<ll>    vl;
typedef vector<pii>   vpii;
typedef vector<pl>    vpl;
typedef vector<vi>    vvi;
typedef vector<vl>    vvl;
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
int rng(int lim) {
  uniform_int_distribution<int> uid(0, lim - 1);
  return uid(rang);
}
ll mpow(ll base, ll exp);
ll power(ll a,ll b);

const ll mod = 1000000007;
//const int N = 3e5, M = N;
  vi g[300001];
  // map<pii,int> w;
  int vis[300001];
  ll res[300001];
  ll sum[300001];

  ll sz[300001];
 //int dist[300001];

//=====================================================================
// struct node
// {
//   ll sum,wt_sum;
// };
// struct operatr
// {
//   int a,d;
// };
struct segTree
{
  int arr[2001];
  int res[8003];

  //int operation_arr[4003];
  int NO_OPERATION=0;

  void init(int x,int lo,int hi)
  {
    //operation_arr[x]=NO_OPERATION;

    if(lo==hi){

      res[x]=arr[lo];
      return;
    }

    int mid=(lo+hi)/2;
    init(2*x,lo,mid);
    init(2*x+1,mid+1,hi);

    //update(x,lo,hi);
    update_point(x);
  }

  // int merge_operation(ll a,ll b)//apply operation b to a
  // {
  //   return a+b;
  // }

  // int operate(int a,int o,int lo,int hi)
  // {
  //   int len=hi-lo+1;
  //   return a+len*o;
  // }

  // ll merge_results(ll a, ll b)
  // {
  //   return (a+b);
  // }

  // void modify(int x,int lo, int hi, int l, int r,int op)
  // {
  //   prop(x,lo,hi);

  //   if(lo>=l&&hi<=r){
  //     operation_arr[x]=merge_operation(operation_arr[x],op);
  //     return;
  //   }

  //   int mid=(lo+hi)/2;

  //   if(lo>r||hi<l)
  //     return;

  //   modify(2*x,lo,mid,l,r,op);
  //   modify(2*x+1,mid+1,hi,l,r,op);

  //   update(x,lo,hi);
  // }
  int get_sum(int x,int lo,int hi,int l,int r)
  {
    if(lo>=l&&hi<=r)
      return res[x];

    if(lo>r||hi<l)
      return 0;

    int mid=(lo+hi)/2;
    return get_sum(2*x,lo,mid,l,r)+get_sum(2*x+1,mid+1,hi,l,r);
  }

  void point_modify(int x,int lo,int hi,int pos,ll val)
  {
    if(lo==hi)
    {
      res[x]+=val;
      return;
    }

    int mid=(lo+hi)/2;

    if(pos<=mid)
      point_modify(2*x,lo,mid,pos,val);
    else
      point_modify(2*x+1,mid+1,hi,pos,val);
    update_point(x);
  }

  void update_point(int x)
  {
    res[x]=min(res[2*x],res[2*x+1]);
  }

  // int query(int x,int lo,int hi,int l,int r)
  // {
  //   //prop(x,lo,hi);

  //   if(lo>=l&&hi<=r)
  //     return operate(res[x],operation_arr[x],lo,hi);

  //   int mid=(hi+lo)/2;
  //   int res;

  //   if(r<=mid)
  //      res=query(2*x,lo,mid,l,r);
  //   else if(l>mid)
  //     res= query(2*x+1,mid+1,hi,l,r);
  //   else
  //     res= merge_results(query(2*x,lo,mid,l,r),query(2*x+1,mid+1,hi,l,r));

  //   return res;

  // }

  ll point_query(int x,int lo, int hi, int val)
  {
    //prop(x,lo,hi);

    if(lo==hi)
      return lo;

    int mid=(lo+hi)/2;

    int v1=res[2*x];

    if(v1==val)
      return point_query(2*x,lo,mid,val);
    else
      return point_query(2*x+1,mid+1,hi,val);
  }

  // void prop(int x,int lo, int hi)
  // {
  //   if(lo==hi)
  //     return;

  //   int mid=(hi+lo)/2;
  //   ll len=mid-lo+1;

  //   operation_arr[2*x]=merge_operation(operation_arr[2*x],operation_arr[x]);
  //   operation_arr[2*x+1]=merge_operation(operation_arr[2*x+1],operation_arr[x]);

  //   operation_arr[x]=NO_OPERATION;

  //   update(x,lo,hi);
  // }

  // void update(int x,int lo,int hi)
  // {
  //   if(lo==hi)
  //     return;
  //   int mid=(lo+hi)/2;
  //   ll len1=(mid-lo+1);
  //   ll len2=(hi-mid);
  //   res[x]=merge_results(operate(res[2*x],operation_arr[2*x],lo,mid),operate(res[2*x+1],operation_arr[2*x+1],mid+1,hi));
  // }

};
struct  FenwickTree
{
  int arr[100];
  int n;

  void update(int i,int delta)
  {
    while(i<=n)
    {
      arr[i]+=delta;
      i=i+(i&(-i));
    }
  }

  int sum(int i)
  {
    if(i==0)
      return 0;
    int res=0;
    while(i>0)
    {
      res=res+arr[i];
      i-=(i&(-i));
    }

    return res;
  }

};

ll dist(pl p1,pl p2)
{
  return abs(p1.F-p2.F)+abs(p1.S-p2.S);
}

ll get_max(vpl pts,int strt,ll t)
{
  int cnt=1;
  ll time=t;

  int mn_idx=strt;
  int mx_idx=strt;

  for(int i=strt;i>=0;i--)
  {
    pl p1=pts[i];
    pl p2=pts[strt];

    if(dist(p1,p2)<=time)
      mn_idx=i;
  }

  cnt+=(strt-mn_idx);

  time-=2*dist(pts[strt],pts[mn_idx]);

  int c1=0;
  int mx_idx2=strt;
  for(int i=strt;i<pts.size();i++)
  {
    pl p1=pts[strt];
    pl p2=pts[i];

    if(dist(p1,p2)<=time)
      mx_idx=i;
    if(dist(p1,p2)<=t)
      mx_idx2=i;
  }

  cnt=cnt+(mx_idx-strt);

  return max(cnt,mx_idx2-strt+1);

}

struct dsu
{
  int par[1001];
  int size_set[1001];

  int get_par(int u)
  {
    vi temp;
    while(par[u]!=u)
    {
      temp.pb(u);
      u=par[u];
    }

    for(int i:temp)
      par[i]=u;

    return u;
  }

  void union_set(int a,int b)
  {
    a=get_par(a);
    b=get_par(b);

    if(a==b)
      return;
    if(size_set[a]<size_set[b])
    {
      int temp=a;
      a=b;
      b=temp;
    }

    //assuming a to have a larger size
    par[b]=a;

    size_set[a]+=size_set[b];
    // transfer all elements in b to a

  }

};
struct query
{
  string s;
  int u,v;
};

int b_search(vi a, int v,int end)
{
  int l=0,r=end;
  int res=-1;

  while(l<=r)
  {
    int mid=l+(r-l)/2;

    if(a[mid]>=v)
      res=mid,r=mid-1;
    else
      l=mid+1;
  }

  return res;
}
ll dist(ll a,ll b,ll c,ll d,ll e)
{
  if(a==-1&&b==-1&&c==-1)
    return abs(d-e);
  if(a==-1&&b==-1)
    return abs(c-e)+abs(d-e);

  return abs(a-e)+abs(b-e)+abs(c-e)+abs(d-e);
}

ll binary_s(ll a,ll b,ll c,ll d)
{
  ll l=1,r=1000000000;

  ll res=-1;

  while(l<=r)
  {
    ll mid=l+(r-l)/2;

    ll d1=dist(a,b,c,d,mid),d2=dist(a,b,c,d,mid-1),d3=dist(a,b,c,d,mid+1);

    if(d1<=d2&&d1<=d3)
    {
      res=d1;
      break;
    }
    if(d2>=d1&&d3<=d1)
      l=mid+1;
    else
      r=mid-1;
  }

  return res;
}
struct result
{
  ll i1,j1,x;
};
void solve()
{
  int n;
  cin>>n;

  ll a[n];

  for(int i=0;i<n;i++)
    cin>>a[i];

  ll anding=0;

  vi o(300005);
  vi z(300005);

  ll pw[64];
  pw[0]=1;
  for(int i=1;i<=32;i++)
    pw[i]=pw[i-1]*2;

  ll res=0;ll inv_cnt=0;

  for(ll i=29;i>=0;i--)
  {
    ll t1=i+1;
    anding=anding+(pw[t1]);
    unordered_map<int,int> mp;
    int cnt=0;

    ll over_o_z=0,over_z_o=0;
    ll v=pw[i];

    for(int j=0;j<n;j++)
    {
      ll k=(a[j]&anding);
      k=(k>>i);

      if(mp.find(k)==mp.end())
      {
        mp[k]=cnt;

        o[cnt]=0;
        z[cnt]=0;

        ll t2=(a[j]&v);

        if(t2==0)
          over_o_z+=o[cnt],z[cnt]++;
        else
          over_z_o+=z[cnt],o[cnt]++;

        cnt++;
      }
      else
      {
        ll t2=(a[j]&v);

        ll v3=mp[k];

        if(t2==0)
          over_o_z+=o[v3],z[v3]++;
        else
          over_z_o+=z[v3],o[v3]++;
      }
    }

    if(over_o_z>over_z_o)
    {
      ll v1=pw[i];
      res=res+v1;
    }
    inv_cnt+=min(over_z_o,over_o_z);

  }

  cout<<inv_cnt<<" "<<res<<"\n";
}

int main()
{

    #ifndef ONLINE_JUDGE
          freopen("input.txt","r",stdin);
          freopen("output.txt","w",stdout);
    #endif

    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    srand(chrono::high_resolution_clock::now().time_since_epoch().count());
    //seive();

    int t = 1;
    //cin >> t;
    while(t--)
    {
        solve();
    }

    return 0;
}
//=======================================================================================
ll mpow(ll base, ll exp)
{
    base %= mod;
    ll result = 1;
    while (exp > 0)
    {
        if (exp & 1)
          result = ((ll)result * base) % mod;
        base = ((ll)base * base) % mod;
        exp >>= 1;
  }
  return result;
}

ll power(ll a,ll b)
{
  ll res=1;
  while(b>0)
  {
    if(b%2==0)
    {
      b/=2;
      a=a*a;
    }
    else
    {
      res=res*a;
      b--;
    }
  }
  return res;
}


#include<bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define Fo(i,n) for(int i=0;i<n;i++)
#define fo(i,k,n) for(int i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long
#define si(x) scanf("%d",&x)
#define sl(x) scanf("%lld",&x)
#define ss(s) scanf("%s",s)
#define pi(x) printf("%d\n",x)
#define pl(x) printf("%lld\n",x)
#define ps(s) printf("%s\n",s)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
typedef pair<int, int>  pii;
typedef pair<ll, ll>  pl;
typedef vector<int>   vi;
typedef vector<ll>    vl;
typedef vector<pii>   vpii;
typedef vector<pl>    vpl;
typedef vector<vi>    vvi;
typedef vector<vl>    vvl;
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
int rng(int lim) {
  uniform_int_distribution<int> uid(0, lim - 1);
  return uid(rang);
}
ll mpow(ll base, ll exp);
ll power(ll a,ll b);

const ll mod = 1000000007;
//const int N = 3e5, M = N;
  vi g[300001];
  // map<pii,int> w;
  int vis[300001];
  ll res[300001];
  ll sum[300001];

  ll sz[300001];
 //int dist[300001];

//=====================================================================
// struct node
// {
//   ll sum,wt_sum;
// };
// struct operatr
// {
//   int a,d;
// };
struct segTree
{
  int arr[2001];
  int res[8003];

  //int operation_arr[4003];
  int NO_OPERATION=0;

  void init(int x,int lo,int hi)
  {
    //operation_arr[x]=NO_OPERATION;

    if(lo==hi){

      res[x]=arr[lo];
      return;
    }

    int mid=(lo+hi)/2;
    init(2*x,lo,mid);
    init(2*x+1,mid+1,hi);

    //update(x,lo,hi);
    update_point(x);
  }

  // int merge_operation(ll a,ll b)//apply operation b to a
  // {
  //   return a+b;
  // }

  // int operate(int a,int o,int lo,int hi)
  // {
  //   int len=hi-lo+1;
  //   return a+len*o;
  // }

  // ll merge_results(ll a, ll b)
  // {
  //   return (a+b);
  // }

  // void modify(int x,int lo, int hi, int l, int r,int op)
  // {
  //   prop(x,lo,hi);

  //   if(lo>=l&&hi<=r){
  //     operation_arr[x]=merge_operation(operation_arr[x],op);
  //     return;
  //   }

  //   int mid=(lo+hi)/2;

  //   if(lo>r||hi<l)
  //     return;

  //   modify(2*x,lo,mid,l,r,op);
  //   modify(2*x+1,mid+1,hi,l,r,op);

  //   update(x,lo,hi);
  // }
  int get_sum(int x,int lo,int hi,int l,int r)
  {
    if(lo>=l&&hi<=r)
      return res[x];

    if(lo>r||hi<l)
      return 0;

    int mid=(lo+hi)/2;
    return get_sum(2*x,lo,mid,l,r)+get_sum(2*x+1,mid+1,hi,l,r);
  }

  void point_modify(int x,int lo,int hi,int pos,ll val)
  {
    if(lo==hi)
    {
      res[x]+=val;
      return;
    }

    int mid=(lo+hi)/2;

    if(pos<=mid)
      point_modify(2*x,lo,mid,pos,val);
    else
      point_modify(2*x+1,mid+1,hi,pos,val);
    update_point(x);
  }

  void update_point(int x)
  {
    res[x]=min(res[2*x],res[2*x+1]);
  }

  // int query(int x,int lo,int hi,int l,int r)
  // {
  //   //prop(x,lo,hi);

  //   if(lo>=l&&hi<=r)
  //     return operate(res[x],operation_arr[x],lo,hi);

  //   int mid=(hi+lo)/2;
  //   int res;

  //   if(r<=mid)
  //      res=query(2*x,lo,mid,l,r);
  //   else if(l>mid)
  //     res= query(2*x+1,mid+1,hi,l,r);
  //   else
  //     res= merge_results(query(2*x,lo,mid,l,r),query(2*x+1,mid+1,hi,l,r));

  //   return res;

  // }

  ll point_query(int x,int lo, int hi, int val)
  {
    //prop(x,lo,hi);

    if(lo==hi)
      return lo;

    int mid=(lo+hi)/2;

    int v1=res[2*x];

    if(v1==val)
      return point_query(2*x,lo,mid,val);
    else
      return point_query(2*x+1,mid+1,hi,val);
  }

  // void prop(int x,int lo, int hi)
  // {
  //   if(lo==hi)
  //     return;

  //   int mid=(hi+lo)/2;
  //   ll len=mid-lo+1;

  //   operation_arr[2*x]=merge_operation(operation_arr[2*x],operation_arr[x]);
  //   operation_arr[2*x+1]=merge_operation(operation_arr[2*x+1],operation_arr[x]);

  //   operation_arr[x]=NO_OPERATION;

  //   update(x,lo,hi);
  // }

  // void update(int x,int lo,int hi)
  // {
  //   if(lo==hi)
  //     return;
  //   int mid=(lo+hi)/2;
  //   ll len1=(mid-lo+1);
  //   ll len2=(hi-mid);
  //   res[x]=merge_results(operate(res[2*x],operation_arr[2*x],lo,mid),operate(res[2*x+1],operation_arr[2*x+1],mid+1,hi));
  // }

};
struct  FenwickTree
{
  int arr[100];
  int n;

  void update(int i,int delta)
  {
    while(i<=n)
    {
      arr[i]+=delta;
      i=i+(i&(-i));
    }
  }

  int sum(int i)
  {
    if(i==0)
      return 0;
    int res=0;
    while(i>0)
    {
      res=res+arr[i];
      i-=(i&(-i));
    }

    return res;
  }

};

ll dist(pl p1,pl p2)
{
  return abs(p1.F-p2.F)+abs(p1.S-p2.S);
}

ll get_max(vpl pts,int strt,ll t)
{
  int cnt=1;
  ll time=t;

  int mn_idx=strt;
  int mx_idx=strt;

  for(int i=strt;i>=0;i--)
  {
    pl p1=pts[i];
    pl p2=pts[strt];

    if(dist(p1,p2)<=time)
      mn_idx=i;
  }

  cnt+=(strt-mn_idx);

  time-=2*dist(pts[strt],pts[mn_idx]);

  int c1=0;
  int mx_idx2=strt;
  for(int i=strt;i<pts.size();i++)
  {
    pl p1=pts[strt];
    pl p2=pts[i];

    if(dist(p1,p2)<=time)
      mx_idx=i;
    if(dist(p1,p2)<=t)
      mx_idx2=i;
  }

  cnt=cnt+(mx_idx-strt);

  return max(cnt,mx_idx2-strt+1);

}

struct dsu
{
  int par[1001];
  int size_set[1001];

  int get_par(int u)
  {
    vi temp;
    while(par[u]!=u)
    {
      temp.pb(u);
      u=par[u];
    }

    for(int i:temp)
      par[i]=u;

    return u;
  }

  void union_set(int a,int b)
  {
    a=get_par(a);
    b=get_par(b);

    if(a==b)
      return;
    if(size_set[a]<size_set[b])
    {
      int temp=a;
      a=b;
      b=temp;
    }

    //assuming a to have a larger size
    par[b]=a;

    size_set[a]+=size_set[b];
    // transfer all elements in b to a

  }

};
struct query
{
  string s;
  int u,v;
};

int b_search(vi a, int v,int end)
{
  int l=0,r=end;
  int res=-1;

  while(l<=r)
  {
    int mid=l+(r-l)/2;

    if(a[mid]>=v)
      res=mid,r=mid-1;
    else
      l=mid+1;
  }

  return res;
}
ll dist(ll a,ll b,ll c,ll d,ll e)
{
  if(a==-1&&b==-1&&c==-1)
    return abs(d-e);
  if(a==-1&&b==-1)
    return abs(c-e)+abs(d-e);

  return abs(a-e)+abs(b-e)+abs(c-e)+abs(d-e);
}

ll binary_s(ll a,ll b,ll c,ll d)
{
  ll l=1,r=1000000000;

  ll res=-1;

  while(l<=r)
  {
    ll mid=l+(r-l)/2;

    ll d1=dist(a,b,c,d,mid),d2=dist(a,b,c,d,mid-1),d3=dist(a,b,c,d,mid+1);

    if(d1<=d2&&d1<=d3)
    {
      res=d1;
      break;
    }
    if(d2>=d1&&d3<=d1)
      l=mid+1;
    else
      r=mid-1;
  }

  return res;
}
struct result
{
  ll i1,j1,x;
};
void solve()
{
  int n;
  cin>>n;

  ll a[n];

  for(int i=0;i<n;i++)
    cin>>a[i];

  ll anding=0;

  vi temp[300005];

  ll res=0;ll inv_cnt=0;

  for(ll i=30;i>=0;i--)
  {
    ll t1=i+1;
    anding=anding+(1<<t1);
    unordered_map<ll,ll> mp;
    int cnt=0;

    ll over_o_z=0,over_z_o=0;

    for(int j=0;j<n;j++)
    {
      ll k=(a[j]&anding);
      if(mp.find(k)==mp.end())
      {
        mp[k]=cnt;
        temp[cnt].clear();

        temp[cnt].pb(a[j]);
        cnt++;
      }
      else
      {
        temp[mp[k]].pb(a[j]);
      }
    }

    for(int j=0;j<=cnt;j++)
    {
      vl bits;
      for(int l=0;l<temp[j].size();l++)
      {
        if((temp[j][l]&(1<<i))==0)
          bits.pb(0);
        else
          bits.pb(1);
      }

      ll z_o=0,o_z=0;
      ll o_cnt=0,z_cnt=0;

      for(int t=0;t<bits.size();t++)
      {
        if(bits[t]==0)
        {
          o_z=o_z+o_cnt;
          z_cnt++;
        }
        else
        {
          z_o+=z_cnt;
          o_cnt++;
        }
      }
      over_z_o+=z_o;
      over_o_z+=o_z;

      // if(o_z>z_o)
      // {
      //   res=res+(1<<i);
      // }

      // inv_cnt+=min(o_z,z_o);
    }
    if(over_o_z>over_z_o)
    {
      res=res+(1<<i);
    }
    inv_cnt+=min(over_z_o,over_o_z);

  }

  cout<<inv_cnt<<" "<<res<<"\n";
}

int main()
{

    #ifndef ONLINE_JUDGE
          freopen("input.txt","r",stdin);
          freopen("output.txt","w",stdout);
    #endif

    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    srand(chrono::high_resolution_clock::now().time_since_epoch().count());
    //seive();

    int t = 1;
    //cin >> t;
    while(t--)
    {
        solve();
    }

    return 0;
}
//=======================================================================================
ll mpow(ll base, ll exp)
{
    base %= mod;
    ll result = 1;
    while (exp > 0)
    {
        if (exp & 1)
          result = ((ll)result * base) % mod;
        base = ((ll)base * base) % mod;
        exp >>= 1;
  }
  return result;
}

ll power(ll a,ll b)
{
  ll res=1;
  while(b>0)
  {
    if(b%2==0)
    {
      b/=2;
      a=a*a;
    }
    else
    {
      res=res*a;
      b--;
    }
  }
  return res;
}


#include<bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define Fo(i,n) for(int i=0;i<n;i++)
#define fo(i,k,n) for(int i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long
#define si(x) scanf("%d",&x)
#define sl(x) scanf("%lld",&x)
#define ss(s) scanf("%s",s)
#define pi(x) printf("%d\n",x)
#define pl(x) printf("%lld\n",x)
#define ps(s) printf("%s\n",s)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
typedef pair<int, int>  pii;
typedef pair<ll, ll>  pl;
typedef vector<int>   vi;
typedef vector<ll>    vl;
typedef vector<pii>   vpii;
typedef vector<pl>    vpl;
typedef vector<vi>    vvi;
typedef vector<vl>    vvl;
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
int rng(int lim) {
  uniform_int_distribution<int> uid(0, lim - 1);
  return uid(rang);
}
ll mpow(ll base, ll exp);
ll power(ll a,ll b);

const ll mod = 1000000007;
//const int N = 3e5, M = N;
  vi g[300001];
  // map<pii,int> w;
  int vis[300001];
  ll res[300001];
  ll sum[300001];

  ll sz[300001];
 //int dist[300001];

//=====================================================================
// struct node
// {
//   ll sum,wt_sum;
// };
// struct operatr
// {
//   int a,d;
// };
struct segTree
{
  int arr[2001];
  int res[8003];

  //int operation_arr[4003];
  int NO_OPERATION=0;

  void init(int x,int lo,int hi)
  {
    //operation_arr[x]=NO_OPERATION;

    if(lo==hi){

      res[x]=arr[lo];
      return;
    }

    int mid=(lo+hi)/2;
    init(2*x,lo,mid);
    init(2*x+1,mid+1,hi);

    //update(x,lo,hi);
    update_point(x);
  }

  // int merge_operation(ll a,ll b)//apply operation b to a
  // {
  //   return a+b;
  // }

  // int operate(int a,int o,int lo,int hi)
  // {
  //   int len=hi-lo+1;
  //   return a+len*o;
  // }

  // ll merge_results(ll a, ll b)
  // {
  //   return (a+b);
  // }

  // void modify(int x,int lo, int hi, int l, int r,int op)
  // {
  //   prop(x,lo,hi);

  //   if(lo>=l&&hi<=r){
  //     operation_arr[x]=merge_operation(operation_arr[x],op);
  //     return;
  //   }

  //   int mid=(lo+hi)/2;

  //   if(lo>r||hi<l)
  //     return;

  //   modify(2*x,lo,mid,l,r,op);
  //   modify(2*x+1,mid+1,hi,l,r,op);

  //   update(x,lo,hi);
  // }
  int get_sum(int x,int lo,int hi,int l,int r)
  {
    if(lo>=l&&hi<=r)
      return res[x];

    if(lo>r||hi<l)
      return 0;

    int mid=(lo+hi)/2;
    return get_sum(2*x,lo,mid,l,r)+get_sum(2*x+1,mid+1,hi,l,r);
  }

  void point_modify(int x,int lo,int hi,int pos,ll val)
  {
    if(lo==hi)
    {
      res[x]+=val;
      return;
    }

    int mid=(lo+hi)/2;

    if(pos<=mid)
      point_modify(2*x,lo,mid,pos,val);
    else
      point_modify(2*x+1,mid+1,hi,pos,val);
    update_point(x);
  }

  void update_point(int x)
  {
    res[x]=min(res[2*x],res[2*x+1]);
  }

  // int query(int x,int lo,int hi,int l,int r)
  // {
  //   //prop(x,lo,hi);

  //   if(lo>=l&&hi<=r)
  //     return operate(res[x],operation_arr[x],lo,hi);

  //   int mid=(hi+lo)/2;
  //   int res;

  //   if(r<=mid)
  //      res=query(2*x,lo,mid,l,r);
  //   else if(l>mid)
  //     res= query(2*x+1,mid+1,hi,l,r);
  //   else
  //     res= merge_results(query(2*x,lo,mid,l,r),query(2*x+1,mid+1,hi,l,r));

  //   return res;

  // }

  ll point_query(int x,int lo, int hi, int val)
  {
    //prop(x,lo,hi);

    if(lo==hi)
      return lo;

    int mid=(lo+hi)/2;

    int v1=res[2*x];

    if(v1==val)
      return point_query(2*x,lo,mid,val);
    else
      return point_query(2*x+1,mid+1,hi,val);
  }

  // void prop(int x,int lo, int hi)
  // {
  //   if(lo==hi)
  //     return;

  //   int mid=(hi+lo)/2;
  //   ll len=mid-lo+1;

  //   operation_arr[2*x]=merge_operation(operation_arr[2*x],operation_arr[x]);
  //   operation_arr[2*x+1]=merge_operation(operation_arr[2*x+1],operation_arr[x]);

  //   operation_arr[x]=NO_OPERATION;

  //   update(x,lo,hi);
  // }

  // void update(int x,int lo,int hi)
  // {
  //   if(lo==hi)
  //     return;
  //   int mid=(lo+hi)/2;
  //   ll len1=(mid-lo+1);
  //   ll len2=(hi-mid);
  //   res[x]=merge_results(operate(res[2*x],operation_arr[2*x],lo,mid),operate(res[2*x+1],operation_arr[2*x+1],mid+1,hi));
  // }

};
struct  FenwickTree
{
  int arr[100];
  int n;

  void update(int i,int delta)
  {
    while(i<=n)
    {
      arr[i]+=delta;
      i=i+(i&(-i));
    }
  }

  int sum(int i)
  {
    if(i==0)
      return 0;
    int res=0;
    while(i>0)
    {
      res=res+arr[i];
      i-=(i&(-i));
    }

    return res;
  }

};

ll dist(pl p1,pl p2)
{
  return abs(p1.F-p2.F)+abs(p1.S-p2.S);
}

ll get_max(vpl pts,int strt,ll t)
{
  int cnt=1;
  ll time=t;

  int mn_idx=strt;
  int mx_idx=strt;

  for(int i=strt;i>=0;i--)
  {
    pl p1=pts[i];
    pl p2=pts[strt];

    if(dist(p1,p2)<=time)
      mn_idx=i;
  }

  cnt+=(strt-mn_idx);

  time-=2*dist(pts[strt],pts[mn_idx]);

  int c1=0;
  int mx_idx2=strt;
  for(int i=strt;i<pts.size();i++)
  {
    pl p1=pts[strt];
    pl p2=pts[i];

    if(dist(p1,p2)<=time)
      mx_idx=i;
    if(dist(p1,p2)<=t)
      mx_idx2=i;
  }

  cnt=cnt+(mx_idx-strt);

  return max(cnt,mx_idx2-strt+1);

}

struct dsu
{
  int par[1001];
  int size_set[1001];

  int get_par(int u)
  {
    vi temp;
    while(par[u]!=u)
    {
      temp.pb(u);
      u=par[u];
    }

    for(int i:temp)
      par[i]=u;

    return u;
  }

  void union_set(int a,int b)
  {
    a=get_par(a);
    b=get_par(b);

    if(a==b)
      return;
    if(size_set[a]<size_set[b])
    {
      int temp=a;
      a=b;
      b=temp;
    }

    //assuming a to have a larger size
    par[b]=a;

    size_set[a]+=size_set[b];
    // transfer all elements in b to a

  }

};
struct query
{
  string s;
  int u,v;
};

int b_search(vi a, int v,int end)
{
  int l=0,r=end;
  int res=-1;

  while(l<=r)
  {
    int mid=l+(r-l)/2;

    if(a[mid]>=v)
      res=mid,r=mid-1;
    else
      l=mid+1;
  }

  return res;
}
ll dist(ll a,ll b,ll c,ll d,ll e)
{
  if(a==-1&&b==-1&&c==-1)
    return abs(d-e);
  if(a==-1&&b==-1)
    return abs(c-e)+abs(d-e);

  return abs(a-e)+abs(b-e)+abs(c-e)+abs(d-e);
}

ll binary_s(ll a,ll b,ll c,ll d)
{
  ll l=1,r=1000000000;

  ll res=-1;

  while(l<=r)
  {
    ll mid=l+(r-l)/2;

    ll d1=dist(a,b,c,d,mid),d2=dist(a,b,c,d,mid-1),d3=dist(a,b,c,d,mid+1);

    if(d1<=d2&&d1<=d3)
    {
      res=d1;
      break;
    }
    if(d2>=d1&&d3<=d1)
      l=mid+1;
    else
      r=mid-1;
  }

  return res;
}
struct result
{
  ll i1,j1,x;
};
void solve()
{
  int n;
  cin>>n;

  ll a[n];

  for(int i=0;i<n;i++)
    cin>>a[i];

  ll anding=0;

  vi temp[300005];

  ll pw[64];
  for(int i=0;i<=32;i++)
    pw[i]=power(2,i);

  ll res=0;ll inv_cnt=0;

  for(ll i=31;i>=0;i--)
  {
    ll t1=i+1;
    anding=anding+(pw[t1]);
    unordered_map<ll,ll> mp;
    int cnt=0;

    ll over_o_z=0,over_z_o=0;

    for(int j=0;j<n;j++)
    {
      ll k=(a[j]&anding);
      if(mp.find(k)==mp.end())
      {
        mp[k]=cnt;
        temp[cnt].clear();

        temp[cnt].pb(a[j]);
        cnt++;
      }
      else
      {
        temp[mp[k]].pb(a[j]);
      }
    }

    for(int j=0;j<=cnt;j++)
    {
      vl bits;
      for(int l=0;l<temp[j].size();l++)
      {
        ll v=pw[i];
        if((temp[j][l]&v)==0)
          bits.pb(0);
        else
          bits.pb(1);
      }

      ll z_o=0,o_z=0;
      ll o_cnt=0,z_cnt=0;

      for(int t=0;t<bits.size();t++)
      {
        if(bits[t]==0)
        {
          o_z=o_z+o_cnt;
          z_cnt++;
        }
        else
        {
          z_o+=z_cnt;
          o_cnt++;
        }
      }
      over_z_o+=z_o;
      over_o_z+=o_z;

      // if(o_z>z_o)
      // {
      //   res=res+(1<<i);
      // }

      // inv_cnt+=min(o_z,z_o);
    }
    if(over_o_z>over_z_o)
    {
      res=res+(1<<i);
    }
    inv_cnt+=min(over_z_o,over_o_z);

  }

  cout<<inv_cnt<<" "<<res<<"\n";
}

int main()
{

    #ifndef ONLINE_JUDGE
          freopen("input.txt","r",stdin);
          freopen("output.txt","w",stdout);
    #endif

    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    srand(chrono::high_resolution_clock::now().time_since_epoch().count());
    //seive();

    int t = 1;
    //cin >> t;
    while(t--)
    {
        solve();
    }

    return 0;
}
//=======================================================================================
ll mpow(ll base, ll exp)
{
    base %= mod;
    ll result = 1;
    while (exp > 0)
    {
        if (exp & 1)
          result = ((ll)result * base) % mod;
        base = ((ll)base * base) % mod;
        exp >>= 1;
  }
  return result;
}

ll power(ll a,ll b)
{
  ll res=1;
  while(b>0)
  {
    if(b%2==0)
    {
      b/=2;
      a=a*a;
    }
    else
    {
      res=res*a;
      b--;
    }
  }
  return res;
}


#include<bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define Fo(i,n) for(int i=0;i<n;i++)
#define fo(i,k,n) for(int i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long
#define si(x) scanf("%d",&x)
#define sl(x) scanf("%lld",&x)
#define ss(s) scanf("%s",s)
#define pi(x) printf("%d\n",x)
#define pl(x) printf("%lld\n",x)
#define ps(s) printf("%s\n",s)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
typedef pair<int, int>  pii;
typedef pair<ll, ll>  pl;
typedef vector<int>   vi;
typedef vector<ll>    vl;
typedef vector<pii>   vpii;
typedef vector<pl>    vpl;
typedef vector<vi>    vvi;
typedef vector<vl>    vvl;
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
int rng(int lim) {
  uniform_int_distribution<int> uid(0, lim - 1);
  return uid(rang);
}
ll mpow(ll base, ll exp);
ll power(ll a,ll b);

const ll mod = 1000000007;
//const int N = 3e5, M = N;
  vi g[300001];
  // map<pii,int> w;
  int vis[300001];
  ll res[300001];
  ll sum[300001];

  ll sz[300001];
 //int dist[300001];

//=====================================================================
// struct node
// {
//   ll sum,wt_sum;
// };
// struct operatr
// {
//   int a,d;
// };
struct segTree
{
  int arr[2001];
  int res[8003];

  //int operation_arr[4003];
  int NO_OPERATION=0;

  void init(int x,int lo,int hi)
  {
    //operation_arr[x]=NO_OPERATION;

    if(lo==hi){

      res[x]=arr[lo];
      return;
    }

    int mid=(lo+hi)/2;
    init(2*x,lo,mid);
    init(2*x+1,mid+1,hi);

    //update(x,lo,hi);
    update_point(x);
  }

  // int merge_operation(ll a,ll b)//apply operation b to a
  // {
  //   return a+b;
  // }

  // int operate(int a,int o,int lo,int hi)
  // {
  //   int len=hi-lo+1;
  //   return a+len*o;
  // }

  // ll merge_results(ll a, ll b)
  // {
  //   return (a+b);
  // }

  // void modify(int x,int lo, int hi, int l, int r,int op)
  // {
  //   prop(x,lo,hi);

  //   if(lo>=l&&hi<=r){
  //     operation_arr[x]=merge_operation(operation_arr[x],op);
  //     return;
  //   }

  //   int mid=(lo+hi)/2;

  //   if(lo>r||hi<l)
  //     return;

  //   modify(2*x,lo,mid,l,r,op);
  //   modify(2*x+1,mid+1,hi,l,r,op);

  //   update(x,lo,hi);
  // }
  int get_sum(int x,int lo,int hi,int l,int r)
  {
    if(lo>=l&&hi<=r)
      return res[x];

    if(lo>r||hi<l)
      return 0;

    int mid=(lo+hi)/2;
    return get_sum(2*x,lo,mid,l,r)+get_sum(2*x+1,mid+1,hi,l,r);
  }

  void point_modify(int x,int lo,int hi,int pos,ll val)
  {
    if(lo==hi)
    {
      res[x]+=val;
      return;
    }

    int mid=(lo+hi)/2;

    if(pos<=mid)
      point_modify(2*x,lo,mid,pos,val);
    else
      point_modify(2*x+1,mid+1,hi,pos,val);
    update_point(x);
  }

  void update_point(int x)
  {
    res[x]=min(res[2*x],res[2*x+1]);
  }

  // int query(int x,int lo,int hi,int l,int r)
  // {
  //   //prop(x,lo,hi);

  //   if(lo>=l&&hi<=r)
  //     return operate(res[x],operation_arr[x],lo,hi);

  //   int mid=(hi+lo)/2;
  //   int res;

  //   if(r<=mid)
  //      res=query(2*x,lo,mid,l,r);
  //   else if(l>mid)
  //     res= query(2*x+1,mid+1,hi,l,r);
  //   else
  //     res= merge_results(query(2*x,lo,mid,l,r),query(2*x+1,mid+1,hi,l,r));

  //   return res;

  // }

  ll point_query(int x,int lo, int hi, int val)
  {
    //prop(x,lo,hi);

    if(lo==hi)
      return lo;

    int mid=(lo+hi)/2;

    int v1=res[2*x];

    if(v1==val)
      return point_query(2*x,lo,mid,val);
    else
      return point_query(2*x+1,mid+1,hi,val);
  }

  // void prop(int x,int lo, int hi)
  // {
  //   if(lo==hi)
  //     return;

  //   int mid=(hi+lo)/2;
  //   ll len=mid-lo+1;

  //   operation_arr[2*x]=merge_operation(operation_arr[2*x],operation_arr[x]);
  //   operation_arr[2*x+1]=merge_operation(operation_arr[2*x+1],operation_arr[x]);

  //   operation_arr[x]=NO_OPERATION;

  //   update(x,lo,hi);
  // }

  // void update(int x,int lo,int hi)
  // {
  //   if(lo==hi)
  //     return;
  //   int mid=(lo+hi)/2;
  //   ll len1=(mid-lo+1);
  //   ll len2=(hi-mid);
  //   res[x]=merge_results(operate(res[2*x],operation_arr[2*x],lo,mid),operate(res[2*x+1],operation_arr[2*x+1],mid+1,hi));
  // }

};
struct  FenwickTree
{
  int arr[100];
  int n;

  void update(int i,int delta)
  {
    while(i<=n)
    {
      arr[i]+=delta;
      i=i+(i&(-i));
    }
  }

  int sum(int i)
  {
    if(i==0)
      return 0;
    int res=0;
    while(i>0)
    {
      res=res+arr[i];
      i-=(i&(-i));
    }

    return res;
  }

};

ll dist(pl p1,pl p2)
{
  return abs(p1.F-p2.F)+abs(p1.S-p2.S);
}

ll get_max(vpl pts,int strt,ll t)
{
  int cnt=1;
  ll time=t;

  int mn_idx=strt;
  int mx_idx=strt;

  for(int i=strt;i>=0;i--)
  {
    pl p1=pts[i];
    pl p2=pts[strt];

    if(dist(p1,p2)<=time)
      mn_idx=i;
  }

  cnt+=(strt-mn_idx);

  time-=2*dist(pts[strt],pts[mn_idx]);

  int c1=0;
  int mx_idx2=strt;
  for(int i=strt;i<pts.size();i++)
  {
    pl p1=pts[strt];
    pl p2=pts[i];

    if(dist(p1,p2)<=time)
      mx_idx=i;
    if(dist(p1,p2)<=t)
      mx_idx2=i;
  }

  cnt=cnt+(mx_idx-strt);

  return max(cnt,mx_idx2-strt+1);

}

struct dsu
{
  int par[1001];
  int size_set[1001];

  int get_par(int u)
  {
    vi temp;
    while(par[u]!=u)
    {
      temp.pb(u);
      u=par[u];
    }

    for(int i:temp)
      par[i]=u;

    return u;
  }

  void union_set(int a,int b)
  {
    a=get_par(a);
    b=get_par(b);

    if(a==b)
      return;
    if(size_set[a]<size_set[b])
    {
      int temp=a;
      a=b;
      b=temp;
    }

    //assuming a to have a larger size
    par[b]=a;

    size_set[a]+=size_set[b];
    // transfer all elements in b to a

  }

};
struct query
{
  string s;
  int u,v;
};

int b_search(vi a, int v,int end)
{
  int l=0,r=end;
  int res=-1;

  while(l<=r)
  {
    int mid=l+(r-l)/2;

    if(a[mid]>=v)
      res=mid,r=mid-1;
    else
      l=mid+1;
  }

  return res;
}
ll dist(ll a,ll b,ll c,ll d,ll e)
{
  if(a==-1&&b==-1&&c==-1)
    return abs(d-e);
  if(a==-1&&b==-1)
    return abs(c-e)+abs(d-e);

  return abs(a-e)+abs(b-e)+abs(c-e)+abs(d-e);
}

ll binary_s(ll a,ll b,ll c,ll d)
{
  ll l=1,r=1000000000;

  ll res=-1;

  while(l<=r)
  {
    ll mid=l+(r-l)/2;

    ll d1=dist(a,b,c,d,mid),d2=dist(a,b,c,d,mid-1),d3=dist(a,b,c,d,mid+1);

    if(d1<=d2&&d1<=d3)
    {
      res=d1;
      break;
    }
    if(d2>=d1&&d3<=d1)
      l=mid+1;
    else
      r=mid-1;
  }

  return res;
}
struct result
{
  ll i1,j1,x;
};
void solve()
{
  int n;
  cin>>n;

  ll a[n];

  for(int i=0;i<n;i++)
    cin>>a[i];

  ll anding=0;

  vi o(300005);
  vi z(300005);

  ll pw[64];
  pw[0]=1;
  for(int i=1;i<=32;i++)
    pw[i]=pw[i-1]*2;

  ll res=0;ll inv_cnt=0;

  for(ll i=31;i>=0;i--)
  {
    ll t1=i+1;
    anding=anding+(pw[t1]);
    unordered_map<ll,ll> mp;
    int cnt=0;

    ll over_o_z=0,over_z_o=0;
    ll v=pw[i];

    for(int j=0;j<n;j++)
    {
      ll k=(a[j]&anding);
      if(mp.find(k)==mp.end())
      {
        mp[k]=cnt;

        o[cnt]=0;
        z[cnt]=0;

        ll t2=(a[j]&v);

        if(t2==0)
          over_o_z+=o[cnt],z[cnt]++;
        else
          over_z_o+=z[cnt],o[cnt]++;

        cnt++;
      }
      else
      {
        ll t2=(a[j]&v);

        if(t2==0)
          over_o_z+=o[mp[k]],z[mp[k]]++;
        else
          over_z_o+=z[mp[k]],o[mp[k]]++;
      }
    }

    if(over_o_z>over_z_o)
    {
      ll v1=pw[i];
      res=res+v1;
    }
    inv_cnt+=min(over_z_o,over_o_z);

  }

  cout<<inv_cnt<<" "<<res<<"\n";
}

int main()
{

    #ifndef ONLINE_JUDGE
          freopen("input.txt","r",stdin);
          freopen("output.txt","w",stdout);
    #endif

    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    srand(chrono::high_resolution_clock::now().time_since_epoch().count());
    //seive();

    int t = 1;
    //cin >> t;
    while(t--)
    {
        solve();
    }

    return 0;
}
//=======================================================================================
ll mpow(ll base, ll exp)
{
    base %= mod;
    ll result = 1;
    while (exp > 0)
    {
        if (exp & 1)
          result = ((ll)result * base) % mod;
        base = ((ll)base * base) % mod;
        exp >>= 1;
  }
  return result;
}

ll power(ll a,ll b)
{
  ll res=1;
  while(b>0)
  {
    if(b%2==0)
    {
      b/=2;
      a=a*a;
    }
    else
    {
      res=res*a;
      b--;
    }
  }
  return res;
}


#include<bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define Fo(i,n) for(int i=0;i<n;i++)
#define fo(i,k,n) for(int i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long
#define si(x) scanf("%d",&x)
#define sl(x) scanf("%lld",&x)
#define ss(s) scanf("%s",s)
#define pi(x) printf("%d\n",x)
#define pl(x) printf("%lld\n",x)
#define ps(s) printf("%s\n",s)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
typedef pair<int, int>  pii;
typedef pair<ll, ll>  pl;
typedef vector<int>   vi;
typedef vector<ll>    vl;
typedef vector<pii>   vpii;
typedef vector<pl>    vpl;
typedef vector<vi>    vvi;
typedef vector<vl>    vvl;
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
int rng(int lim) {
  uniform_int_distribution<int> uid(0, lim - 1);
  return uid(rang);
}
ll mpow(ll base, ll exp);
ll power(ll a,ll b);

const ll mod = 1000000007;
//const int N = 3e5, M = N;
  vi g[300001];
  // map<pii,int> w;
  int vis[300001];
  ll res[300001];
  ll sum[300001];

  ll sz[300001];
 //int dist[300001];

//=====================================================================
// struct node
// {
//   ll sum,wt_sum;
// };
// struct operatr
// {
//   int a,d;
// };
struct segTree
{
  int arr[2001];
  int res[8003];

  //int operation_arr[4003];
  int NO_OPERATION=0;

  void init(int x,int lo,int hi)
  {
    //operation_arr[x]=NO_OPERATION;

    if(lo==hi){

      res[x]=arr[lo];
      return;
    }

    int mid=(lo+hi)/2;
    init(2*x,lo,mid);
    init(2*x+1,mid+1,hi);

    //update(x,lo,hi);
    update_point(x);
  }

  // int merge_operation(ll a,ll b)//apply operation b to a
  // {
  //   return a+b;
  // }

  // int operate(int a,int o,int lo,int hi)
  // {
  //   int len=hi-lo+1;
  //   return a+len*o;
  // }

  // ll merge_results(ll a, ll b)
  // {
  //   return (a+b);
  // }

  // void modify(int x,int lo, int hi, int l, int r,int op)
  // {
  //   prop(x,lo,hi);

  //   if(lo>=l&&hi<=r){
  //     operation_arr[x]=merge_operation(operation_arr[x],op);
  //     return;
  //   }

  //   int mid=(lo+hi)/2;

  //   if(lo>r||hi<l)
  //     return;

  //   modify(2*x,lo,mid,l,r,op);
  //   modify(2*x+1,mid+1,hi,l,r,op);

  //   update(x,lo,hi);
  // }
  int get_sum(int x,int lo,int hi,int l,int r)
  {
    if(lo>=l&&hi<=r)
      return res[x];

    if(lo>r||hi<l)
      return 0;

    int mid=(lo+hi)/2;
    return get_sum(2*x,lo,mid,l,r)+get_sum(2*x+1,mid+1,hi,l,r);
  }

  void point_modify(int x,int lo,int hi,int pos,ll val)
  {
    if(lo==hi)
    {
      res[x]+=val;
      return;
    }

    int mid=(lo+hi)/2;

    if(pos<=mid)
      point_modify(2*x,lo,mid,pos,val);
    else
      point_modify(2*x+1,mid+1,hi,pos,val);
    update_point(x);
  }

  void update_point(int x)
  {
    res[x]=min(res[2*x],res[2*x+1]);
  }

  // int query(int x,int lo,int hi,int l,int r)
  // {
  //   //prop(x,lo,hi);

  //   if(lo>=l&&hi<=r)
  //     return operate(res[x],operation_arr[x],lo,hi);

  //   int mid=(hi+lo)/2;
  //   int res;

  //   if(r<=mid)
  //      res=query(2*x,lo,mid,l,r);
  //   else if(l>mid)
  //     res= query(2*x+1,mid+1,hi,l,r);
  //   else
  //     res= merge_results(query(2*x,lo,mid,l,r),query(2*x+1,mid+1,hi,l,r));

  //   return res;

  // }

  ll point_query(int x,int lo, int hi, int val)
  {
    //prop(x,lo,hi);

    if(lo==hi)
      return lo;

    int mid=(lo+hi)/2;

    int v1=res[2*x];

    if(v1==val)
      return point_query(2*x,lo,mid,val);
    else
      return point_query(2*x+1,mid+1,hi,val);
  }

  // void prop(int x,int lo, int hi)
  // {
  //   if(lo==hi)
  //     return;

  //   int mid=(hi+lo)/2;
  //   ll len=mid-lo+1;

  //   operation_arr[2*x]=merge_operation(operation_arr[2*x],operation_arr[x]);
  //   operation_arr[2*x+1]=merge_operation(operation_arr[2*x+1],operation_arr[x]);

  //   operation_arr[x]=NO_OPERATION;

  //   update(x,lo,hi);
  // }

  // void update(int x,int lo,int hi)
  // {
  //   if(lo==hi)
  //     return;
  //   int mid=(lo+hi)/2;
  //   ll len1=(mid-lo+1);
  //   ll len2=(hi-mid);
  //   res[x]=merge_results(operate(res[2*x],operation_arr[2*x],lo,mid),operate(res[2*x+1],operation_arr[2*x+1],mid+1,hi));
  // }

};
struct  FenwickTree
{
  int arr[100];
  int n;

  void update(int i,int delta)
  {
    while(i<=n)
    {
      arr[i]+=delta;
      i=i+(i&(-i));
    }
  }

  int sum(int i)
  {
    if(i==0)
      return 0;
    int res=0;
    while(i>0)
    {
      res=res+arr[i];
      i-=(i&(-i));
    }

    return res;
  }

};

ll dist(pl p1,pl p2)
{
  return abs(p1.F-p2.F)+abs(p1.S-p2.S);
}

ll get_max(vpl pts,int strt,ll t)
{
  int cnt=1;
  ll time=t;

  int mn_idx=strt;
  int mx_idx=strt;

  for(int i=strt;i>=0;i--)
  {
    pl p1=pts[i];
    pl p2=pts[strt];

    if(dist(p1,p2)<=time)
      mn_idx=i;
  }

  cnt+=(strt-mn_idx);

  time-=2*dist(pts[strt],pts[mn_idx]);

  int c1=0;
  int mx_idx2=strt;
  for(int i=strt;i<pts.size();i++)
  {
    pl p1=pts[strt];
    pl p2=pts[i];

    if(dist(p1,p2)<=time)
      mx_idx=i;
    if(dist(p1,p2)<=t)
      mx_idx2=i;
  }

  cnt=cnt+(mx_idx-strt);

  return max(cnt,mx_idx2-strt+1);

}

struct dsu
{
  int par[1001];
  int size_set[1001];

  int get_par(int u)
  {
    vi temp;
    while(par[u]!=u)
    {
      temp.pb(u);
      u=par[u];
    }

    for(int i:temp)
      par[i]=u;

    return u;
  }

  void union_set(int a,int b)
  {
    a=get_par(a);
    b=get_par(b);

    if(a==b)
      return;
    if(size_set[a]<size_set[b])
    {
      int temp=a;
      a=b;
      b=temp;
    }

    //assuming a to have a larger size
    par[b]=a;

    size_set[a]+=size_set[b];
    // transfer all elements in b to a

  }

};
struct query
{
  string s;
  int u,v;
};

int b_search(vi a, int v,int end)
{
  int l=0,r=end;
  int res=-1;

  while(l<=r)
  {
    int mid=l+(r-l)/2;

    if(a[mid]>=v)
      res=mid,r=mid-1;
    else
      l=mid+1;
  }

  return res;
}
ll dist(ll a,ll b,ll c,ll d,ll e)
{
  if(a==-1&&b==-1&&c==-1)
    return abs(d-e);
  if(a==-1&&b==-1)
    return abs(c-e)+abs(d-e);

  return abs(a-e)+abs(b-e)+abs(c-e)+abs(d-e);
}

ll binary_s(ll a,ll b,ll c,ll d)
{
  ll l=1,r=1000000000;

  ll res=-1;

  while(l<=r)
  {
    ll mid=l+(r-l)/2;

    ll d1=dist(a,b,c,d,mid),d2=dist(a,b,c,d,mid-1),d3=dist(a,b,c,d,mid+1);

    if(d1<=d2&&d1<=d3)
    {
      res=d1;
      break;
    }
    if(d2>=d1&&d3<=d1)
      l=mid+1;
    else
      r=mid-1;
  }

  return res;
}
struct result
{
  ll i1,j1,x;
};
void solve()
{
  int n;
  cin>>n;

  ll a[n];

  for(int i=0;i<n;i++)
    cin>>a[i];

  ll anding=0;

  vi o(3005);
  vi z(3005);

  ll pw[64];
  pw[0]=1;
  for(int i=1;i<=32;i++)
    pw[i]=pw[i-1]*2;

  ll res=0;ll inv_cnt=0;

  for(ll i=31;i>=0;i--)
  {
    ll t1=i+1;
    anding=anding+(pw[t1]);
    map<ll,ll> mp;
    int cnt=0;

    ll over_o_z=0,over_z_o=0;
    ll v=pw[i];

    for(int j=0;j<n;j++)
    {
      ll k=(a[j]&anding);
      if(mp.find(k)==mp.end())
      {
        mp[k]=cnt;

        o[cnt]=0;
        z[cnt]=0;

        ll t2=(a[j]&v);

        if(t2==0)
          over_o_z+=o[cnt],z[cnt]++;
        else
          over_z_o+=z[cnt],o[cnt]++;

        cnt++;
      }
      else
      {
        ll t2=(a[j]&v);

        ll v3=mp[k];

        if(t2==0)
          over_o_z+=o[v3],z[v3]++;
        else
          over_z_o+=z[v3],o[v3]++;
      }
    }

    if(over_o_z>over_z_o)
    {
      ll v1=pw[i];
      res=res+v1;
    }
    inv_cnt+=min(over_z_o,over_o_z);

  }

  cout<<inv_cnt<<" "<<res<<"\n";
}

int main()
{

    #ifndef ONLINE_JUDGE
          freopen("input.txt","r",stdin);
          freopen("output.txt","w",stdout);
    #endif

    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    srand(chrono::high_resolution_clock::now().time_since_epoch().count());
    //seive();

    int t = 1;
    //cin >> t;
    while(t--)
    {
        solve();
    }

    return 0;
}
//=======================================================================================
ll mpow(ll base, ll exp)
{
    base %= mod;
    ll result = 1;
    while (exp > 0)
    {
        if (exp & 1)
          result = ((ll)result * base) % mod;
        base = ((ll)base * base) % mod;
        exp >>= 1;
  }
  return result;
}

ll power(ll a,ll b)
{
  ll res=1;
  while(b>0)
  {
    if(b%2==0)
    {
      b/=2;
      a=a*a;
    }
    else
    {
      res=res*a;
      b--;
    }
  }
  return res;
}


#include<bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define Fo(i,n) for(int i=0;i<n;i++)
#define fo(i,k,n) for(int i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long
#define si(x) scanf("%d",&x)
#define sl(x) scanf("%lld",&x)
#define ss(s) scanf("%s",s)
#define pi(x) printf("%d\n",x)
#define pl(x) printf("%lld\n",x)
#define ps(s) printf("%s\n",s)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
typedef pair<int, int>  pii;
typedef pair<ll, ll>  pl;
typedef vector<int>   vi;
typedef vector<ll>    vl;
typedef vector<pii>   vpii;
typedef vector<pl>    vpl;
typedef vector<vi>    vvi;
typedef vector<vl>    vvl;
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
int rng(int lim) {
  uniform_int_distribution<int> uid(0, lim - 1);
  return uid(rang);
}
ll mpow(ll base, ll exp);
ll power(ll a,ll b);

const ll mod = 1000000007;
//const int N = 3e5, M = N;
  vi g[300001];
  // map<pii,int> w;
  int vis[300001];
  ll res[300001];
  ll sum[300001];

  ll sz[300001];
 //int dist[300001];

//=====================================================================
// struct node
// {
//   ll sum,wt_sum;
// };
// struct operatr
// {
//   int a,d;
// };
struct segTree
{
  int arr[2001];
  int res[8003];

  //int operation_arr[4003];
  int NO_OPERATION=0;

  void init(int x,int lo,int hi)
  {
    //operation_arr[x]=NO_OPERATION;

    if(lo==hi){

      res[x]=arr[lo];
      return;
    }

    int mid=(lo+hi)/2;
    init(2*x,lo,mid);
    init(2*x+1,mid+1,hi);

    //update(x,lo,hi);
    update_point(x);
  }

  // int merge_operation(ll a,ll b)//apply operation b to a
  // {
  //   return a+b;
  // }

  // int operate(int a,int o,int lo,int hi)
  // {
  //   int len=hi-lo+1;
  //   return a+len*o;
  // }

  // ll merge_results(ll a, ll b)
  // {
  //   return (a+b);
  // }

  // void modify(int x,int lo, int hi, int l, int r,int op)
  // {
  //   prop(x,lo,hi);

  //   if(lo>=l&&hi<=r){
  //     operation_arr[x]=merge_operation(operation_arr[x],op);
  //     return;
  //   }

  //   int mid=(lo+hi)/2;

  //   if(lo>r||hi<l)
  //     return;

  //   modify(2*x,lo,mid,l,r,op);
  //   modify(2*x+1,mid+1,hi,l,r,op);

  //   update(x,lo,hi);
  // }
  int get_sum(int x,int lo,int hi,int l,int r)
  {
    if(lo>=l&&hi<=r)
      return res[x];

    if(lo>r||hi<l)
      return 0;

    int mid=(lo+hi)/2;
    return get_sum(2*x,lo,mid,l,r)+get_sum(2*x+1,mid+1,hi,l,r);
  }

  void point_modify(int x,int lo,int hi,int pos,ll val)
  {
    if(lo==hi)
    {
      res[x]+=val;
      return;
    }

    int mid=(lo+hi)/2;

    if(pos<=mid)
      point_modify(2*x,lo,mid,pos,val);
    else
      point_modify(2*x+1,mid+1,hi,pos,val);
    update_point(x);
  }

  void update_point(int x)
  {
    res[x]=min(res[2*x],res[2*x+1]);
  }

  // int query(int x,int lo,int hi,int l,int r)
  // {
  //   //prop(x,lo,hi);

  //   if(lo>=l&&hi<=r)
  //     return operate(res[x],operation_arr[x],lo,hi);

  //   int mid=(hi+lo)/2;
  //   int res;

  //   if(r<=mid)
  //      res=query(2*x,lo,mid,l,r);
  //   else if(l>mid)
  //     res= query(2*x+1,mid+1,hi,l,r);
  //   else
  //     res= merge_results(query(2*x,lo,mid,l,r),query(2*x+1,mid+1,hi,l,r));

  //   return res;

  // }

  ll point_query(int x,int lo, int hi, int val)
  {
    //prop(x,lo,hi);

    if(lo==hi)
      return lo;

    int mid=(lo+hi)/2;

    int v1=res[2*x];

    if(v1==val)
      return point_query(2*x,lo,mid,val);
    else
      return point_query(2*x+1,mid+1,hi,val);
  }

  // void prop(int x,int lo, int hi)
  // {
  //   if(lo==hi)
  //     return;

  //   int mid=(hi+lo)/2;
  //   ll len=mid-lo+1;

  //   operation_arr[2*x]=merge_operation(operation_arr[2*x],operation_arr[x]);
  //   operation_arr[2*x+1]=merge_operation(operation_arr[2*x+1],operation_arr[x]);

  //   operation_arr[x]=NO_OPERATION;

  //   update(x,lo,hi);
  // }

  // void update(int x,int lo,int hi)
  // {
  //   if(lo==hi)
  //     return;
  //   int mid=(lo+hi)/2;
  //   ll len1=(mid-lo+1);
  //   ll len2=(hi-mid);
  //   res[x]=merge_results(operate(res[2*x],operation_arr[2*x],lo,mid),operate(res[2*x+1],operation_arr[2*x+1],mid+1,hi));
  // }

};
struct  FenwickTree
{
  int arr[100];
  int n;

  void update(int i,int delta)
  {
    while(i<=n)
    {
      arr[i]+=delta;
      i=i+(i&(-i));
    }
  }

  int sum(int i)
  {
    if(i==0)
      return 0;
    int res=0;
    while(i>0)
    {
      res=res+arr[i];
      i-=(i&(-i));
    }

    return res;
  }

};

ll dist(pl p1,pl p2)
{
  return abs(p1.F-p2.F)+abs(p1.S-p2.S);
}

ll get_max(vpl pts,int strt,ll t)
{
  int cnt=1;
  ll time=t;

  int mn_idx=strt;
  int mx_idx=strt;

  for(int i=strt;i>=0;i--)
  {
    pl p1=pts[i];
    pl p2=pts[strt];

    if(dist(p1,p2)<=time)
      mn_idx=i;
  }

  cnt+=(strt-mn_idx);

  time-=2*dist(pts[strt],pts[mn_idx]);

  int c1=0;
  int mx_idx2=strt;
  for(int i=strt;i<pts.size();i++)
  {
    pl p1=pts[strt];
    pl p2=pts[i];

    if(dist(p1,p2)<=time)
      mx_idx=i;
    if(dist(p1,p2)<=t)
      mx_idx2=i;
  }

  cnt=cnt+(mx_idx-strt);

  return max(cnt,mx_idx2-strt+1);

}

struct dsu
{
  int par[1001];
  int size_set[1001];

  int get_par(int u)
  {
    vi temp;
    while(par[u]!=u)
    {
      temp.pb(u);
      u=par[u];
    }

    for(int i:temp)
      par[i]=u;

    return u;
  }

  void union_set(int a,int b)
  {
    a=get_par(a);
    b=get_par(b);

    if(a==b)
      return;
    if(size_set[a]<size_set[b])
    {
      int temp=a;
      a=b;
      b=temp;
    }

    //assuming a to have a larger size
    par[b]=a;

    size_set[a]+=size_set[b];
    // transfer all elements in b to a

  }

};
struct query
{
  string s;
  int u,v;
};

int b_search(vi a, int v,int end)
{
  int l=0,r=end;
  int res=-1;

  while(l<=r)
  {
    int mid=l+(r-l)/2;

    if(a[mid]>=v)
      res=mid,r=mid-1;
    else
      l=mid+1;
  }

  return res;
}
ll dist(ll a,ll b,ll c,ll d,ll e)
{
  if(a==-1&&b==-1&&c==-1)
    return abs(d-e);
  if(a==-1&&b==-1)
    return abs(c-e)+abs(d-e);

  return abs(a-e)+abs(b-e)+abs(c-e)+abs(d-e);
}

ll binary_s(ll a,ll b,ll c,ll d)
{
  ll l=1,r=1000000000;

  ll res=-1;

  while(l<=r)
  {
    ll mid=l+(r-l)/2;

    ll d1=dist(a,b,c,d,mid),d2=dist(a,b,c,d,mid-1),d3=dist(a,b,c,d,mid+1);

    if(d1<=d2&&d1<=d3)
    {
      res=d1;
      break;
    }
    if(d2>=d1&&d3<=d1)
      l=mid+1;
    else
      r=mid-1;
  }

  return res;
}
struct result
{
  ll i1,j1,x;
};
void solve()
{
  int n;
  cin>>n;

  ll a[n];

  for(int i=0;i<n;i++)
    cin>>a[i];

  ll anding=0;

  vi o(300005);
  vi z(300005);

  ll pw[64];
  pw[0]=1;
  for(int i=1;i<=32;i++)
    pw[i]=pw[i-1]*2;

  ll res=0;ll inv_cnt=0;

  for(ll i=29;i>=0;i--)
  {
    ll t1=i+1;
    anding=anding+(pw[t1]);
    unordered_map<int,int> mp;
    int cnt=0;

    ll over_o_z=0,over_z_o=0;
    ll v=pw[i];

    for(int j=0;j<n;j++)
    {
      ll k=(a[j]&anding);
      if(mp.find(k)==mp.end())
      {
        mp[k]=cnt;

        o[cnt]=0;
        z[cnt]=0;

        ll t2=(a[j]&v);

        if(t2==0)
          over_o_z+=o[cnt],z[cnt]++;
        else
          over_z_o+=z[cnt],o[cnt]++;

        cnt++;
      }
      else
      {
        ll t2=(a[j]&v);

        ll v3=mp[k];

        if(t2==0)
          over_o_z+=o[v3],z[v3]++;
        else
          over_z_o+=z[v3],o[v3]++;
      }
    }

    if(over_o_z>over_z_o)
    {
      ll v1=pw[i];
      res=res+v1;
    }
    inv_cnt+=min(over_z_o,over_o_z);

  }

  cout<<inv_cnt<<" "<<res<<"\n";
}

int main()
{

    #ifndef ONLINE_JUDGE
          freopen("input.txt","r",stdin);
          freopen("output.txt","w",stdout);
    #endif

    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    srand(chrono::high_resolution_clock::now().time_since_epoch().count());
    //seive();

    int t = 1;
    //cin >> t;
    while(t--)
    {
        solve();
    }

    return 0;
}
//=======================================================================================
ll mpow(ll base, ll exp)
{
    base %= mod;
    ll result = 1;
    while (exp > 0)
    {
        if (exp & 1)
          result = ((ll)result * base) % mod;
        base = ((ll)base * base) % mod;
        exp >>= 1;
  }
  return result;
}

ll power(ll a,ll b)
{
  ll res=1;
  while(b>0)
  {
    if(b%2==0)
    {
      b/=2;
      a=a*a;
    }
    else
    {
      res=res*a;
      b--;
    }
  }
  return res;
}


#include<bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define Fo(i,n) for(int i=0;i<n;i++)
#define fo(i,k,n) for(int i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long
#define si(x) scanf("%d",&x)
#define sl(x) scanf("%lld",&x)
#define ss(s) scanf("%s",s)
#define pi(x) printf("%d\n",x)
#define pl(x) printf("%lld\n",x)
#define ps(s) printf("%s\n",s)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
typedef pair<int, int>  pii;
typedef pair<ll, ll>  pl;
typedef vector<int>   vi;
typedef vector<ll>    vl;
typedef vector<pii>   vpii;
typedef vector<pl>    vpl;
typedef vector<vi>    vvi;
typedef vector<vl>    vvl;
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
int rng(int lim) {
  uniform_int_distribution<int> uid(0, lim - 1);
  return uid(rang);
}
ll mpow(ll base, ll exp);
ll power(ll a,ll b);

const ll mod = 1000000007;
//const int N = 3e5, M = N;
  vi g[300001];
  // map<pii,int> w;
  int vis[300001];
  ll res[300001];
  ll sum[300001];

  ll sz[300001];
 //int dist[300001];

//=====================================================================
// struct node
// {
//   ll sum,wt_sum;
// };
// struct operatr
// {
//   int a,d;
// };
struct segTree
{
  int arr[2001];
  int res[8003];

  //int operation_arr[4003];
  int NO_OPERATION=0;

  void init(int x,int lo,int hi)
  {
    //operation_arr[x]=NO_OPERATION;

    if(lo==hi){

      res[x]=arr[lo];
      return;
    }

    int mid=(lo+hi)/2;
    init(2*x,lo,mid);
    init(2*x+1,mid+1,hi);

    //update(x,lo,hi);
    update_point(x);
  }

  // int merge_operation(ll a,ll b)//apply operation b to a
  // {
  //   return a+b;
  // }

  // int operate(int a,int o,int lo,int hi)
  // {
  //   int len=hi-lo+1;
  //   return a+len*o;
  // }

  // ll merge_results(ll a, ll b)
  // {
  //   return (a+b);
  // }

  // void modify(int x,int lo, int hi, int l, int r,int op)
  // {
  //   prop(x,lo,hi);

  //   if(lo>=l&&hi<=r){
  //     operation_arr[x]=merge_operation(operation_arr[x],op);
  //     return;
  //   }

  //   int mid=(lo+hi)/2;

  //   if(lo>r||hi<l)
  //     return;

  //   modify(2*x,lo,mid,l,r,op);
  //   modify(2*x+1,mid+1,hi,l,r,op);

  //   update(x,lo,hi);
  // }
  int get_sum(int x,int lo,int hi,int l,int r)
  {
    if(lo>=l&&hi<=r)
      return res[x];

    if(lo>r||hi<l)
      return 0;

    int mid=(lo+hi)/2;
    return get_sum(2*x,lo,mid,l,r)+get_sum(2*x+1,mid+1,hi,l,r);
  }

  void point_modify(int x,int lo,int hi,int pos,ll val)
  {
    if(lo==hi)
    {
      res[x]+=val;
      return;
    }

    int mid=(lo+hi)/2;

    if(pos<=mid)
      point_modify(2*x,lo,mid,pos,val);
    else
      point_modify(2*x+1,mid+1,hi,pos,val);
    update_point(x);
  }

  void update_point(int x)
  {
    res[x]=min(res[2*x],res[2*x+1]);
  }

  // int query(int x,int lo,int hi,int l,int r)
  // {
  //   //prop(x,lo,hi);

  //   if(lo>=l&&hi<=r)
  //     return operate(res[x],operation_arr[x],lo,hi);

  //   int mid=(hi+lo)/2;
  //   int res;

  //   if(r<=mid)
  //      res=query(2*x,lo,mid,l,r);
  //   else if(l>mid)
  //     res= query(2*x+1,mid+1,hi,l,r);
  //   else
  //     res= merge_results(query(2*x,lo,mid,l,r),query(2*x+1,mid+1,hi,l,r));

  //   return res;

  // }

  ll point_query(int x,int lo, int hi, int val)
  {
    //prop(x,lo,hi);

    if(lo==hi)
      return lo;

    int mid=(lo+hi)/2;

    int v1=res[2*x];

    if(v1==val)
      return point_query(2*x,lo,mid,val);
    else
      return point_query(2*x+1,mid+1,hi,val);
  }

  // void prop(int x,int lo, int hi)
  // {
  //   if(lo==hi)
  //     return;

  //   int mid=(hi+lo)/2;
  //   ll len=mid-lo+1;

  //   operation_arr[2*x]=merge_operation(operation_arr[2*x],operation_arr[x]);
  //   operation_arr[2*x+1]=merge_operation(operation_arr[2*x+1],operation_arr[x]);

  //   operation_arr[x]=NO_OPERATION;

  //   update(x,lo,hi);
  // }

  // void update(int x,int lo,int hi)
  // {
  //   if(lo==hi)
  //     return;
  //   int mid=(lo+hi)/2;
  //   ll len1=(mid-lo+1);
  //   ll len2=(hi-mid);
  //   res[x]=merge_results(operate(res[2*x],operation_arr[2*x],lo,mid),operate(res[2*x+1],operation_arr[2*x+1],mid+1,hi));
  // }

};
struct  FenwickTree
{
  int arr[100];
  int n;

  void update(int i,int delta)
  {
    while(i<=n)
    {
      arr[i]+=delta;
      i=i+(i&(-i));
    }
  }

  int sum(int i)
  {
    if(i==0)
      return 0;
    int res=0;
    while(i>0)
    {
      res=res+arr[i];
      i-=(i&(-i));
    }

    return res;
  }

};

ll dist(pl p1,pl p2)
{
  return abs(p1.F-p2.F)+abs(p1.S-p2.S);
}

ll get_max(vpl pts,int strt,ll t)
{
  int cnt=1;
  ll time=t;

  int mn_idx=strt;
  int mx_idx=strt;

  for(int i=strt;i>=0;i--)
  {
    pl p1=pts[i];
    pl p2=pts[strt];

    if(dist(p1,p2)<=time)
      mn_idx=i;
  }

  cnt+=(strt-mn_idx);

  time-=2*dist(pts[strt],pts[mn_idx]);

  int c1=0;
  int mx_idx2=strt;
  for(int i=strt;i<pts.size();i++)
  {
    pl p1=pts[strt];
    pl p2=pts[i];

    if(dist(p1,p2)<=time)
      mx_idx=i;
    if(dist(p1,p2)<=t)
      mx_idx2=i;
  }

  cnt=cnt+(mx_idx-strt);

  return max(cnt,mx_idx2-strt+1);

}

struct dsu
{
  int par[1001];
  int size_set[1001];

  int get_par(int u)
  {
    vi temp;
    while(par[u]!=u)
    {
      temp.pb(u);
      u=par[u];
    }

    for(int i:temp)
      par[i]=u;

    return u;
  }

  void union_set(int a,int b)
  {
    a=get_par(a);
    b=get_par(b);

    if(a==b)
      return;
    if(size_set[a]<size_set[b])
    {
      int temp=a;
      a=b;
      b=temp;
    }

    //assuming a to have a larger size
    par[b]=a;

    size_set[a]+=size_set[b];
    // transfer all elements in b to a

  }

};
struct query
{
  string s;
  int u,v;
};

int b_search(vi a, int v,int end)
{
  int l=0,r=end;
  int res=-1;

  while(l<=r)
  {
    int mid=l+(r-l)/2;

    if(a[mid]>=v)
      res=mid,r=mid-1;
    else
      l=mid+1;
  }

  return res;
}
ll dist(ll a,ll b,ll c,ll d,ll e)
{
  if(a==-1&&b==-1&&c==-1)
    return abs(d-e);
  if(a==-1&&b==-1)
    return abs(c-e)+abs(d-e);

  return abs(a-e)+abs(b-e)+abs(c-e)+abs(d-e);
}

ll binary_s(ll a,ll b,ll c,ll d)
{
  ll l=1,r=1000000000;

  ll res=-1;

  while(l<=r)
  {
    ll mid=l+(r-l)/2;

    ll d1=dist(a,b,c,d,mid),d2=dist(a,b,c,d,mid-1),d3=dist(a,b,c,d,mid+1);

    if(d1<=d2&&d1<=d3)
    {
      res=d1;
      break;
    }
    if(d2>=d1&&d3<=d1)
      l=mid+1;
    else
      r=mid-1;
  }

  return res;
}
struct result
{
  ll i1,j1,x;
};
void solve()
{
  int n;
  cin>>n;

  ll a[n];

  for(int i=0;i<n;i++)
    cin>>a[i];

  ll anding=0;

  vi o(300005);
  vi z(300005);

  ll pw[64];
  pw[0]=1;
  for(int i=1;i<=32;i++)
    pw[i]=pw[i-1]*2;

  ll res=0;ll inv_cnt=0;

  for(ll i=31;i>=0;i--)
  {
    ll t1=i+1;
    anding=anding+(pw[t1]);
    map<ll,ll> mp;
    int cnt=0;

    ll over_o_z=0,over_z_o=0;
    ll v=pw[i];

    for(int j=0;j<n;j++)
    {
      ll k=(a[j]&anding);
      if(mp.find(k)==mp.end())
      {
        mp[k]=cnt;

        o[cnt]=0;
        z[cnt]=0;

        ll t2=(a[j]&v);

        if(t2==0)
          over_o_z+=o[cnt],z[cnt]++;
        else
          over_z_o+=z[cnt],o[cnt]++;

        cnt++;
      }
      else
      {
        ll t2=(a[j]&v);

        ll v3=mp[k];

        if(t2==0)
          over_o_z+=o[v3],z[v3]++;
        else
          over_z_o+=z[v3],o[v3]++;
      }
    }

    if(over_o_z>over_z_o)
    {
      ll v1=pw[i];
      res=res+v1;
    }
    inv_cnt+=min(over_z_o,over_o_z);

  }

  cout<<inv_cnt<<" "<<res<<"\n";
}

int main()
{

    #ifndef ONLINE_JUDGE
          freopen("input.txt","r",stdin);
          freopen("output.txt","w",stdout);
    #endif

    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    srand(chrono::high_resolution_clock::now().time_since_epoch().count());
    //seive();

    int t = 1;
    //cin >> t;
    while(t--)
    {
        solve();
    }

    return 0;
}
//=======================================================================================
ll mpow(ll base, ll exp)
{
    base %= mod;
    ll result = 1;
    while (exp > 0)
    {
        if (exp & 1)
          result = ((ll)result * base) % mod;
        base = ((ll)base * base) % mod;
        exp >>= 1;
  }
  return result;
}

ll power(ll a,ll b)
{
  ll res=1;
  while(b>0)
  {
    if(b%2==0)
    {
      b/=2;
      a=a*a;
    }
    else
    {
      res=res*a;
      b--;
    }
  }
  return res;
}


#include<bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define Fo(i,n) for(int i=0;i<n;i++)
#define fo(i,k,n) for(int i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long
#define si(x) scanf("%d",&x)
#define sl(x) scanf("%lld",&x)
#define ss(s) scanf("%s",s)
#define pi(x) printf("%d\n",x)
#define pl(x) printf("%lld\n",x)
#define ps(s) printf("%s\n",s)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
typedef pair<int, int>  pii;
typedef pair<ll, ll>  pl;
typedef vector<int>   vi;
typedef vector<ll>    vl;
typedef vector<pii>   vpii;
typedef vector<pl>    vpl;
typedef vector<vi>    vvi;
typedef vector<vl>    vvl;
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
int rng(int lim) {
  uniform_int_distribution<int> uid(0, lim - 1);
  return uid(rang);
}
ll mpow(ll base, ll exp);
ll power(ll a,ll b);

const ll mod = 1000000007;
//const int N = 3e5, M = N;
  vi g[300001];
  // map<pii,int> w;
  int vis[300001];
  ll res[300001];
  ll sum[300001];

  ll sz[300001];
 //int dist[300001];

//=====================================================================
// struct node
// {
//   ll sum,wt_sum;
// };
// struct operatr
// {
//   int a,d;
// };
struct segTree
{
  int arr[2001];
  int res[8003];

  //int operation_arr[4003];
  int NO_OPERATION=0;

  void init(int x,int lo,int hi)
  {
    //operation_arr[x]=NO_OPERATION;

    if(lo==hi){

      res[x]=arr[lo];
      return;
    }

    int mid=(lo+hi)/2;
    init(2*x,lo,mid);
    init(2*x+1,mid+1,hi);

    //update(x,lo,hi);
    update_point(x);
  }

  // int merge_operation(ll a,ll b)//apply operation b to a
  // {
  //   return a+b;
  // }

  // int operate(int a,int o,int lo,int hi)
  // {
  //   int len=hi-lo+1;
  //   return a+len*o;
  // }

  // ll merge_results(ll a, ll b)
  // {
  //   return (a+b);
  // }

  // void modify(int x,int lo, int hi, int l, int r,int op)
  // {
  //   prop(x,lo,hi);

  //   if(lo>=l&&hi<=r){
  //     operation_arr[x]=merge_operation(operation_arr[x],op);
  //     return;
  //   }

  //   int mid=(lo+hi)/2;

  //   if(lo>r||hi<l)
  //     return;

  //   modify(2*x,lo,mid,l,r,op);
  //   modify(2*x+1,mid+1,hi,l,r,op);

  //   update(x,lo,hi);
  // }
  int get_sum(int x,int lo,int hi,int l,int r)
  {
    if(lo>=l&&hi<=r)
      return res[x];

    if(lo>r||hi<l)
      return 0;

    int mid=(lo+hi)/2;
    return get_sum(2*x,lo,mid,l,r)+get_sum(2*x+1,mid+1,hi,l,r);
  }

  void point_modify(int x,int lo,int hi,int pos,ll val)
  {
    if(lo==hi)
    {
      res[x]+=val;
      return;
    }

    int mid=(lo+hi)/2;

    if(pos<=mid)
      point_modify(2*x,lo,mid,pos,val);
    else
      point_modify(2*x+1,mid+1,hi,pos,val);
    update_point(x);
  }

  void update_point(int x)
  {
    res[x]=min(res[2*x],res[2*x+1]);
  }

  // int query(int x,int lo,int hi,int l,int r)
  // {
  //   //prop(x,lo,hi);

  //   if(lo>=l&&hi<=r)
  //     return operate(res[x],operation_arr[x],lo,hi);

  //   int mid=(hi+lo)/2;
  //   int res;

  //   if(r<=mid)
  //      res=query(2*x,lo,mid,l,r);
  //   else if(l>mid)
  //     res= query(2*x+1,mid+1,hi,l,r);
  //   else
  //     res= merge_results(query(2*x,lo,mid,l,r),query(2*x+1,mid+1,hi,l,r));

  //   return res;

  // }

  ll point_query(int x,int lo, int hi, int val)
  {
    //prop(x,lo,hi);

    if(lo==hi)
      return lo;

    int mid=(lo+hi)/2;

    int v1=res[2*x];

    if(v1==val)
      return point_query(2*x,lo,mid,val);
    else
      return point_query(2*x+1,mid+1,hi,val);
  }

  // void prop(int x,int lo, int hi)
  // {
  //   if(lo==hi)
  //     return;

  //   int mid=(hi+lo)/2;
  //   ll len=mid-lo+1;

  //   operation_arr[2*x]=merge_operation(operation_arr[2*x],operation_arr[x]);
  //   operation_arr[2*x+1]=merge_operation(operation_arr[2*x+1],operation_arr[x]);

  //   operation_arr[x]=NO_OPERATION;

  //   update(x,lo,hi);
  // }

  // void update(int x,int lo,int hi)
  // {
  //   if(lo==hi)
  //     return;
  //   int mid=(lo+hi)/2;
  //   ll len1=(mid-lo+1);
  //   ll len2=(hi-mid);
  //   res[x]=merge_results(operate(res[2*x],operation_arr[2*x],lo,mid),operate(res[2*x+1],operation_arr[2*x+1],mid+1,hi));
  // }

};
struct  FenwickTree
{
  int arr[100];
  int n;

  void update(int i,int delta)
  {
    while(i<=n)
    {
      arr[i]+=delta;
      i=i+(i&(-i));
    }
  }

  int sum(int i)
  {
    if(i==0)
      return 0;
    int res=0;
    while(i>0)
    {
      res=res+arr[i];
      i-=(i&(-i));
    }

    return res;
  }

};

ll dist(pl p1,pl p2)
{
  return abs(p1.F-p2.F)+abs(p1.S-p2.S);
}

ll get_max(vpl pts,int strt,ll t)
{
  int cnt=1;
  ll time=t;

  int mn_idx=strt;
  int mx_idx=strt;

  for(int i=strt;i>=0;i--)
  {
    pl p1=pts[i];
    pl p2=pts[strt];

    if(dist(p1,p2)<=time)
      mn_idx=i;
  }

  cnt+=(strt-mn_idx);

  time-=2*dist(pts[strt],pts[mn_idx]);

  int c1=0;
  int mx_idx2=strt;
  for(int i=strt;i<pts.size();i++)
  {
    pl p1=pts[strt];
    pl p2=pts[i];

    if(dist(p1,p2)<=time)
      mx_idx=i;
    if(dist(p1,p2)<=t)
      mx_idx2=i;
  }

  cnt=cnt+(mx_idx-strt);

  return max(cnt,mx_idx2-strt+1);

}

struct dsu
{
  int par[1001];
  int size_set[1001];

  int get_par(int u)
  {
    vi temp;
    while(par[u]!=u)
    {
      temp.pb(u);
      u=par[u];
    }

    for(int i:temp)
      par[i]=u;

    return u;
  }

  void union_set(int a,int b)
  {
    a=get_par(a);
    b=get_par(b);

    if(a==b)
      return;
    if(size_set[a]<size_set[b])
    {
      int temp=a;
      a=b;
      b=temp;
    }

    //assuming a to have a larger size
    par[b]=a;

    size_set[a]+=size_set[b];
    // transfer all elements in b to a

  }

};
struct query
{
  string s;
  int u,v;
};

int b_search(vi a, int v,int end)
{
  int l=0,r=end;
  int res=-1;

  while(l<=r)
  {
    int mid=l+(r-l)/2;

    if(a[mid]>=v)
      res=mid,r=mid-1;
    else
      l=mid+1;
  }

  return res;
}
ll dist(ll a,ll b,ll c,ll d,ll e)
{
  if(a==-1&&b==-1&&c==-1)
    return abs(d-e);
  if(a==-1&&b==-1)
    return abs(c-e)+abs(d-e);

  return abs(a-e)+abs(b-e)+abs(c-e)+abs(d-e);
}

ll binary_s(ll a,ll b,ll c,ll d)
{
  ll l=1,r=1000000000;

  ll res=-1;

  while(l<=r)
  {
    ll mid=l+(r-l)/2;

    ll d1=dist(a,b,c,d,mid),d2=dist(a,b,c,d,mid-1),d3=dist(a,b,c,d,mid+1);

    if(d1<=d2&&d1<=d3)
    {
      res=d1;
      break;
    }
    if(d2>=d1&&d3<=d1)
      l=mid+1;
    else
      r=mid-1;
  }

  return res;
}
struct result
{
  ll i1,j1,x;
};
void solve()
{
  int n;
  cin>>n;

  vl a;

  for(int i=0;i<n;i++)
  {
    ll u;
    cin>>u;
    a.pb(u);
  }

  //sortall(a);

  ll anding=0;

  vi o(3005);
  vi z(3005);

  ll pw[64];
  pw[0]=1;
  for(int i=1;i<=32;i++)
    pw[i]=pw[i-1]*2;

  ll res=0;ll inv_cnt=0;

  vector<vl> vals;
  vals.pb(a);

  for(ll i=30;i>=0;i--)
  {

    ll v=pw[i+1];

    int cnt=0;

    ll over_o_z=0,over_z_o=0;

    vector<vl> temp;
    for(auto l:vals)
    {
      vl t1,t2;
      for(int j=0;j<l.size();j++)
      {
        if((l[j]&v)==0)
          t1.pb(l[j]);
        else
          t2.pb(l[j]);
      }
      if(t1.size()>0)
        temp.pb(t1);
      if(t2.size()>0)
        temp.pb(t2);
    }

    vals=temp;

    for(auto l: vals)
    {
      ll o=0,z=0;
      for(int j=0;j<l.size();j++)
      {
        if((l[j]&pw[i])==0)
        {
          over_o_z+=o;
          z++;
        }
        else
        {
          over_z_o+=z;
          o++;
        }
      }
    }

    if(over_o_z>over_z_o)
    {
      ll v1=pw[i];
      res=res+v1;
    }
    inv_cnt+=min(over_z_o,over_o_z);

  }

  cout<<inv_cnt<<" "<<res<<"\n";
}

int main()
{

    #ifndef ONLINE_JUDGE
          freopen("input.txt","r",stdin);
          freopen("output.txt","w",stdout);
    #endif

    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    srand(chrono::high_resolution_clock::now().time_since_epoch().count());
    //seive();

    int t = 1;
    //cin >> t;
    while(t--)
    {
        solve();
    }

    return 0;
}
//=======================================================================================
ll mpow(ll base, ll exp)
{
    base %= mod;
    ll result = 1;
    while (exp > 0)
    {
        if (exp & 1)
          result = ((ll)result * base) % mod;
        base = ((ll)base * base) % mod;
        exp >>= 1;
  }
  return result;
}

ll power(ll a,ll b)
{
  ll res=1;
  while(b>0)
  {
    if(b%2==0)
    {
      b/=2;
      a=a*a;
    }
    else
    {
      res=res*a;
      b--;
    }
  }
  return res;
}


#include<bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define Fo(i,n) for(int i=0;i<n;i++)
#define fo(i,k,n) for(int i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long
#define si(x) scanf("%d",&x)
#define sl(x) scanf("%lld",&x)
#define ss(s) scanf("%s",s)
#define pi(x) printf("%d\n",x)
#define pl(x) printf("%lld\n",x)
#define ps(s) printf("%s\n",s)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
typedef pair<int, int>  pii;
typedef pair<ll, ll>  pl;
typedef vector<int>   vi;
typedef vector<ll>    vl;
typedef vector<pii>   vpii;
typedef vector<pl>    vpl;
typedef vector<vi>    vvi;
typedef vector<vl>    vvl;
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
int rng(int lim) {
  uniform_int_distribution<int> uid(0, lim - 1);
  return uid(rang);
}
ll mpow(ll base, ll exp);
ll power(ll a,ll b);

const ll mod = 1000000007;
//const int N = 3e5, M = N;
  vi g[300001];
  // map<pii,int> w;
  int vis[300001];
  ll res[300001];
  ll sum[300001];

  ll sz[300001];
 //int dist[300001];

//=====================================================================
// struct node
// {
//   ll sum,wt_sum;
// };
// struct operatr
// {
//   int a,d;
// };
struct segTree
{
  int arr[2001];
  int res[8003];

  //int operation_arr[4003];
  int NO_OPERATION=0;

  void init(int x,int lo,int hi)
  {
    //operation_arr[x]=NO_OPERATION;

    if(lo==hi){

      res[x]=arr[lo];
      return;
    }

    int mid=(lo+hi)/2;
    init(2*x,lo,mid);
    init(2*x+1,mid+1,hi);

    //update(x,lo,hi);
    update_point(x);
  }

  // int merge_operation(ll a,ll b)//apply operation b to a
  // {
  //   return a+b;
  // }

  // int operate(int a,int o,int lo,int hi)
  // {
  //   int len=hi-lo+1;
  //   return a+len*o;
  // }

  // ll merge_results(ll a, ll b)
  // {
  //   return (a+b);
  // }

  // void modify(int x,int lo, int hi, int l, int r,int op)
  // {
  //   prop(x,lo,hi);

  //   if(lo>=l&&hi<=r){
  //     operation_arr[x]=merge_operation(operation_arr[x],op);
  //     return;
  //   }

  //   int mid=(lo+hi)/2;

  //   if(lo>r||hi<l)
  //     return;

  //   modify(2*x,lo,mid,l,r,op);
  //   modify(2*x+1,mid+1,hi,l,r,op);

  //   update(x,lo,hi);
  // }
  int get_sum(int x,int lo,int hi,int l,int r)
  {
    if(lo>=l&&hi<=r)
      return res[x];

    if(lo>r||hi<l)
      return 0;

    int mid=(lo+hi)/2;
    return get_sum(2*x,lo,mid,l,r)+get_sum(2*x+1,mid+1,hi,l,r);
  }

  void point_modify(int x,int lo,int hi,int pos,ll val)
  {
    if(lo==hi)
    {
      res[x]+=val;
      return;
    }

    int mid=(lo+hi)/2;

    if(pos<=mid)
      point_modify(2*x,lo,mid,pos,val);
    else
      point_modify(2*x+1,mid+1,hi,pos,val);
    update_point(x);
  }

  void update_point(int x)
  {
    res[x]=min(res[2*x],res[2*x+1]);
  }

  // int query(int x,int lo,int hi,int l,int r)
  // {
  //   //prop(x,lo,hi);

  //   if(lo>=l&&hi<=r)
  //     return operate(res[x],operation_arr[x],lo,hi);

  //   int mid=(hi+lo)/2;
  //   int res;

  //   if(r<=mid)
  //      res=query(2*x,lo,mid,l,r);
  //   else if(l>mid)
  //     res= query(2*x+1,mid+1,hi,l,r);
  //   else
  //     res= merge_results(query(2*x,lo,mid,l,r),query(2*x+1,mid+1,hi,l,r));

  //   return res;

  // }

  ll point_query(int x,int lo, int hi, int val)
  {
    //prop(x,lo,hi);

    if(lo==hi)
      return lo;

    int mid=(lo+hi)/2;

    int v1=res[2*x];

    if(v1==val)
      return point_query(2*x,lo,mid,val);
    else
      return point_query(2*x+1,mid+1,hi,val);
  }

  // void prop(int x,int lo, int hi)
  // {
  //   if(lo==hi)
  //     return;

  //   int mid=(hi+lo)/2;
  //   ll len=mid-lo+1;

  //   operation_arr[2*x]=merge_operation(operation_arr[2*x],operation_arr[x]);
  //   operation_arr[2*x+1]=merge_operation(operation_arr[2*x+1],operation_arr[x]);

  //   operation_arr[x]=NO_OPERATION;

  //   update(x,lo,hi);
  // }

  // void update(int x,int lo,int hi)
  // {
  //   if(lo==hi)
  //     return;
  //   int mid=(lo+hi)/2;
  //   ll len1=(mid-lo+1);
  //   ll len2=(hi-mid);
  //   res[x]=merge_results(operate(res[2*x],operation_arr[2*x],lo,mid),operate(res[2*x+1],operation_arr[2*x+1],mid+1,hi));
  // }

};
struct  FenwickTree
{
  int arr[100];
  int n;

  void update(int i,int delta)
  {
    while(i<=n)
    {
      arr[i]+=delta;
      i=i+(i&(-i));
    }
  }

  int sum(int i)
  {
    if(i==0)
      return 0;
    int res=0;
    while(i>0)
    {
      res=res+arr[i];
      i-=(i&(-i));
    }

    return res;
  }

};

ll dist(pl p1,pl p2)
{
  return abs(p1.F-p2.F)+abs(p1.S-p2.S);
}

ll get_max(vpl pts,int strt,ll t)
{
  int cnt=1;
  ll time=t;

  int mn_idx=strt;
  int mx_idx=strt;

  for(int i=strt;i>=0;i--)
  {
    pl p1=pts[i];
    pl p2=pts[strt];

    if(dist(p1,p2)<=time)
      mn_idx=i;
  }

  cnt+=(strt-mn_idx);

  time-=2*dist(pts[strt],pts[mn_idx]);

  int c1=0;
  int mx_idx2=strt;
  for(int i=strt;i<pts.size();i++)
  {
    pl p1=pts[strt];
    pl p2=pts[i];

    if(dist(p1,p2)<=time)
      mx_idx=i;
    if(dist(p1,p2)<=t)
      mx_idx2=i;
  }

  cnt=cnt+(mx_idx-strt);

  return max(cnt,mx_idx2-strt+1);

}

struct dsu
{
  int par[1001];
  int size_set[1001];

  int get_par(int u)
  {
    vi temp;
    while(par[u]!=u)
    {
      temp.pb(u);
      u=par[u];
    }

    for(int i:temp)
      par[i]=u;

    return u;
  }

  void union_set(int a,int b)
  {
    a=get_par(a);
    b=get_par(b);

    if(a==b)
      return;
    if(size_set[a]<size_set[b])
    {
      int temp=a;
      a=b;
      b=temp;
    }

    //assuming a to have a larger size
    par[b]=a;

    size_set[a]+=size_set[b];
    // transfer all elements in b to a

  }

};
struct query
{
  string s;
  int u,v;
};

int b_search(vi a, int v,int end)
{
  int l=0,r=end;
  int res=-1;

  while(l<=r)
  {
    int mid=l+(r-l)/2;

    if(a[mid]>=v)
      res=mid,r=mid-1;
    else
      l=mid+1;
  }

  return res;
}
ll dist(ll a,ll b,ll c,ll d,ll e)
{
  if(a==-1&&b==-1&&c==-1)
    return abs(d-e);
  if(a==-1&&b==-1)
    return abs(c-e)+abs(d-e);

  return abs(a-e)+abs(b-e)+abs(c-e)+abs(d-e);
}

ll binary_s(ll a,ll b,ll c,ll d)
{
  ll l=1,r=1000000000;

  ll res=-1;

  while(l<=r)
  {
    ll mid=l+(r-l)/2;

    ll d1=dist(a,b,c,d,mid),d2=dist(a,b,c,d,mid-1),d3=dist(a,b,c,d,mid+1);

    if(d1<=d2&&d1<=d3)
    {
      res=d1;
      break;
    }
    if(d2>=d1&&d3<=d1)
      l=mid+1;
    else
      r=mid-1;
  }

  return res;
}
struct result
{
  ll i1,j1,x;
};
void solve()
{
  int n;
  cin>>n;

  ll a[n];

  for(int i=0;i<n;i++)
    cin>>a[i];

  ll anding=0;

  vi o(300005);
  vi z(300005);

  ll pw[64];
  pw[0]=1;
  for(int i=1;i<=32;i++)
    pw[i]=pw[i-1]*2;

  ll res=0;ll inv_cnt=0;

  for(ll i=30;i>=0;i--)
  {
    ll t1=i+1;
    anding=anding+(pw[t1]);
    unordered_map<int,int> mp;
    int cnt=0;

    ll over_o_z=0,over_z_o=0;
    ll v=pw[i];

    for(int j=0;j<n;j++)
    {
      ll k=(a[j]&anding);
      if(mp.find(k)==mp.end())
      {
        mp[k]=cnt;

        o[cnt]=0;
        z[cnt]=0;

        ll t2=(a[j]&v);

        if(t2==0)
          over_o_z+=o[cnt],z[cnt]++;
        else
          over_z_o+=z[cnt],o[cnt]++;

        cnt++;
      }
      else
      {
        ll t2=(a[j]&v);

        ll v3=mp[k];

        if(t2==0)
          over_o_z+=o[v3],z[v3]++;
        else
          over_z_o+=z[v3],o[v3]++;
      }
    }

    if(over_o_z>over_z_o)
    {
      ll v1=pw[i];
      res=res+v1;
    }
    inv_cnt+=min(over_z_o,over_o_z);

  }

  cout<<inv_cnt<<" "<<res<<"\n";
}

int main()
{

    #ifndef ONLINE_JUDGE
          freopen("input.txt","r",stdin);
          freopen("output.txt","w",stdout);
    #endif

    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    srand(chrono::high_resolution_clock::now().time_since_epoch().count());
    //seive();

    int t = 1;
    //cin >> t;
    while(t--)
    {
        solve();
    }

    return 0;
}
//=======================================================================================
ll mpow(ll base, ll exp)
{
    base %= mod;
    ll result = 1;
    while (exp > 0)
    {
        if (exp & 1)
          result = ((ll)result * base) % mod;
        base = ((ll)base * base) % mod;
        exp >>= 1;
  }
  return result;
}

ll power(ll a,ll b)
{
  ll res=1;
  while(b>0)
  {
    if(b%2==0)
    {
      b/=2;
      a=a*a;
    }
    else
    {
      res=res*a;
      b--;
    }
  }
  return res;
}


#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

mt19937 rnd(time(nullptr));

int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n; cin >> n;
    vector<int> a(n); for (int i=0; i<n; ++i) cin >> a[i];
    ll ans=0;
    int res=0;
    for (int bit=29; ~bit; --bit) {
        int BIT=(1<<bit);
        ll cnt1=0, cnt2=0;
        unordered_map<int, pair<int, int>> cnt;
        for (auto val : a) {
            if (val&BIT) {
                cnt2+=cnt[val>>(bit+1)].first;
                cnt[val>>(bit+1)].second++;
            }
            else {
                cnt1+=cnt[val>>(bit+1)].second;
                cnt[val>>(bit+1)].first++;
            }
        }
        ans+=min(cnt1, cnt2);
        if (cnt2 < cnt1) res+=BIT;
    }
    cout << ans << " " << res;
}


#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;

//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;

//template<class T> using oset=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
//template<class T> using omultiset=tree<T,null_type,less_equal<T>,rb_tree_tag,tree_order_statistics_node_update>;

//find_by_order
//order_of_key

#define x first
#define y second
#define pb push_back
#define all(a) a.begin(),a.end()

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<pii> vii;
typedef vector<pll> vll;

mt19937 rnd(time(nullptr));

const int N=3e5+5;

int a[N], was[N];

int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n; cin >> n;
    for (int i=1; i<=n; ++i) cin >> a[i];
    int ans=0, res=0;
    for (int bit=(1<<30); bit>=1; bit>>=1) {
        int cnt1=0, cnt2=0;
        unordered_map<int, int> was0, was1;
        for (int i=1; i<=n; ++i) {
            if (a[i]&bit) {cnt2+=was0[was[i]], was1[was[i]]++; continue;}
            cnt1+=was1[was[i]], was0[was[i]]++;
        }
        ans+=min(cnt1, cnt2);
        if (cnt2 < cnt1) {
            res^=bit;
            for (int i=1; i<=n; ++i) a[i]^=bit;
        }
        for (int i=1; i<=n; ++i) if (a[i]&bit) was[i]^=bit;
    }
    cout << ans << " " << res;
}


#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;

//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;

//template<class T> using oset=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
//template<class T> using omultiset=tree<T,null_type,less_equal<T>,rb_tree_tag,tree_order_statistics_node_update>;

//find_by_order
//order_of_key

#define x first
#define y second
#define pb push_back
#define all(a) a.begin(),a.end()

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<pii> vii;
typedef vector<pll> vll;

mt19937 rnd(time(nullptr));

const int N=3e5+5;

int a[N], was[N];

int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n; cin >> n;
    for (int i=1; i<=n; ++i) cin >> a[i];
    ll ans=0, cnt1=0, cnt2=0; int res=0;
    for (int bit=(1<<29); bit>=1; bit>>=1) {
        cnt1=cnt2=0;
        unordered_map<int, int> was0, was1;
        for (int i=1; i<=n; ++i) {
            if (a[i]&bit) {cnt2+=(ll)was0[was[i]], was1[was[i]]++; continue;}
            cnt1+=(ll)was1[was[i]], was0[was[i]]++;
        }
        ans+=min(cnt1, cnt2);
        if (cnt2 < cnt1) {
            res^=bit;
            for (int i=1; i<=n; ++i) a[i]^=bit;
        }
        for (int i=1; i<=n; ++i) if (a[i]&bit) was[i]^=bit;
    }
    cout << ans << " " << res;
}


#pragma GCC optimize("O3")
#pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h>
using namespace std;

//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;

//template<class T> using oset=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
//template<class T> using omultiset=tree<T,null_type,less_equal<T>,rb_tree_tag,tree_order_statistics_node_update>;

//find_by_order
//order_of_key

#define x first
#define y second
#define pb push_back
#define all(a) a.begin(),a.end()

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<pii> vii;
typedef vector<pll> vll;

mt19937 rnd(time(nullptr));

int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n; cin >> n;
    vi a(n); for (int i=0; i<n; ++i) cin >> a[i];
    ll ans=0;
    int res=0;
    for (int bit=29; ~bit; --bit) {
        int BIT=(1<<bit);
        ll cnt1=0, cnt2=0;
        unordered_map<int, pii> cnt;
        for (auto val : a) {
            if (val&BIT) {
                cnt2+=cnt[val>>(bit+1)].x;
                cnt[val>>(bit+1)].y++;
            }
            else {
                cnt1+=cnt[val>>(bit+1)].y;
                cnt[val>>(bit+1)].x++;
            }
        }
        ans+=min(cnt1, cnt2);
        if (cnt2 < cnt1) res+=BIT;
    }
    cout << ans << " " << res;
}


#pragma GCC target ("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h>
using namespace std;

//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;

//template<class T> using oset=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
//template<class T> using omultiset=tree<T,null_type,less_equal<T>,rb_tree_tag,tree_order_statistics_node_update>;

//find_by_order
//order_of_key

#define x first
#define y second
#define pb push_back
#define all(a) a.begin(),a.end()

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<pii> vii;
typedef vector<pll> vll;

mt19937 rnd(time(nullptr));

int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n; cin >> n;
    vi a(n); for (int i=0; i<n; ++i) cin >> a[i];
    ll ans=0;
    int res=0;
    for (int bit=29; ~bit; --bit) {
        int BIT=(1<<bit);
        ll cnt1=0, cnt2=0;
        unordered_map<int, pii> cnt;
        for (auto val : a) {
            if (val&BIT) {
                cnt2+=cnt[val>>(bit+1)].x;
                cnt[val>>(bit+1)].y++;
            }
            else {
                cnt1+=cnt[val>>(bit+1)].y;
                cnt[val>>(bit+1)].x++;
            }
        }
        ans+=min(cnt1, cnt2);
        if (cnt2 < cnt1) res+=BIT;
    }
    cout << ans << " " << res;
}


#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;

//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;

//template<class T> using oset=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
//template<class T> using omultiset=tree<T,null_type,less_equal<T>,rb_tree_tag,tree_order_statistics_node_update>;

//find_by_order
//order_of_key

#define x first
#define y second
#define pb push_back
#define all(a) a.begin(),a.end()

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<pii> vii;
typedef vector<pll> vll;

mt19937 rnd(time(nullptr));

const int N=3e5+5;

int a[N], was[N];

int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n; cin >> n;
    for (int i=1; i<=n; ++i) cin >> a[i];
    ll ans=0; int res=0, cnt1=0, cnt2=0;
    for (int bit=(1<<30); bit>=1; bit>>=1) {
        cnt1=cnt2=0;
        unordered_map<int, int> was0, was1;
        for (int i=1; i<=n; ++i) {
            if (a[i]&bit) {cnt2+=(ll)was0[was[i]], was1[was[i]]++; continue;}
            cnt1+=(ll)was1[was[i]], was0[was[i]]++;
        }
        ans+=min(cnt1, cnt2);
        if (cnt2 < cnt1) {
            res^=bit;
            for (int i=1; i<=n; ++i) a[i]^=bit;
        }
        for (int i=1; i<=n; ++i) if (a[i]&bit) was[i]^=bit;
    }
    cout << ans << " " << res;
}


#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;

//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;

//template<class T> using oset=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
//template<class T> using omultiset=tree<T,null_type,less_equal<T>,rb_tree_tag,tree_order_statistics_node_update>;

//find_by_order
//order_of_key

#define x first
#define y second
#define pb push_back
#define all(a) a.begin(),a.end()

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<pii> vii;
typedef vector<pll> vll;

mt19937 rnd(time(nullptr));

const int N=3e5+5;

int a[N], was[N];

int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n; cin >> n;
    for (int i=1; i<=n; ++i) cin >> a[i];
    ll ans=0, cnt1=0, cnt2=0; int res=0;
    for (int bit=(1<<30); bit>=1; bit>>=1) {
        cnt1=cnt2=0;
        unordered_map<int, int> was0, was1;
        for (int i=1; i<=n; ++i) {
            if (a[i]&bit) {cnt2+=(ll)was0[was[i]], was1[was[i]]++; continue;}
            cnt1+=(ll)was1[was[i]], was0[was[i]]++;
        }
        ans+=min(cnt1, cnt2);
        if (cnt2 < cnt1) {
            res^=bit;
            for (int i=1; i<=n; ++i) a[i]^=bit;
        }
        for (int i=1; i<=n; ++i) if (a[i]&bit) was[i]^=bit;
    }
    cout << ans << " " << res;
}


#include <bits/stdc++.h>

using namespace std;

using ll = long long;

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

mt19937 rnd(time(nullptr));

int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n; cin >> n;
    vector<int> a(n); for (int i=0; i<n; ++i) cin >> a[i];
    ll ans=0;
    int res=0;
    for (int bit=29; ~bit; --bit) {
        int BIT=(1<<bit);
        ll cnt1=0, cnt2=0;
        unordered_map<int, pair<int, int>> cnt;
        for (auto val : a) {
            if (val&BIT) {
                cnt2+=cnt[val>>(bit+1)].first;
                cnt[val>>(bit+1)].second++;
            }
            else {
                cnt1+=cnt[val>>(bit+1)].second;
                cnt[val>>(bit+1)].first++;
            }
        }
        ans+=min(cnt1, cnt2);
        if (cnt2 < cnt1) res+=BIT;
    }
    cout << ans << " " << res;
}


#include <bits/stdc++.h>

using namespace std;

using ll = long long;

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

mt19937 rnd(time(0));

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(nullptr);
    int n; cin >> n;
    vector<int> a(n); for (int i=0; i<n; ++i) cin >> a[i];
    ll ans=0;
    int res=0;
    for (int bit=29; bit>=0; --bit) {
        int BIT=(1<<bit);
        ll cnt1=0, cnt2=0;
        unordered_map<int, pair<int, int>> cnt;
        for (auto val : a) {
            if (val&BIT) {
                cnt2+=cnt[val>>(bit+1)].first;
                cnt[val>>(bit+1)].second++;
            }
            else {
                cnt1+=cnt[val>>(bit+1)].second;
                cnt[val>>(bit+1)].first++;
            }
        }
        ans+=min(cnt1, cnt2);
        if (cnt2 < cnt1) res+=BIT;
    }
    cout << ans << ' ' << res << endl;
}


#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;

//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;

//template<class T> using oset=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
//template<class T> using omultiset=tree<T,null_type,less_equal<T>,rb_tree_tag,tree_order_statistics_node_update>;

//find_by_order
//order_of_key

#define x first
#define y second
#define pb push_back
#define all(a) a.begin(),a.end()

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<pii> vii;
typedef vector<pll> vll;

mt19937 rnd(time(nullptr));

const int N=3e5+5;

ll a[N], was[N];

int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n; cin >> n;
    for (int i=1; i<=n; ++i) cin >> a[i];
    ll ans=0, res=0;
    for (ll bit=(1LL<<30); bit>=1; bit>>=1LL) {
        ll cnt1=0, cnt2=0;
        unordered_map<ll, ll> was0, was1;
        for (int i=1; i<=n; ++i) {
            if (a[i]&bit) {cnt2+=was0[was[i]], was1[was[i]]++; continue;}
            cnt1+=was1[was[i]], was0[was[i]]++;
        }
        ans+=min(cnt1, cnt2);
        if (cnt2 < cnt1) {
            res^=bit;
            for (int i=1; i<=n; ++i) a[i]^=bit;
        }
        for (int i=1; i<=n; ++i) if (a[i]&bit) was[i]^=bit;
    }
    cout << ans << " " << res;
}


#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;

//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;

//template<class T> using oset=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
//template<class T> using omultiset=tree<T,null_type,less_equal<T>,rb_tree_tag,tree_order_statistics_node_update>;

//find_by_order
//order_of_key

#define x first
#define y second
#define pb push_back
#define all(a) a.begin(),a.end()

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<pii> vii;
typedef vector<pll> vll;

mt19937 rnd(time(nullptr));

const int N=3e5+5;

ll a[N], was[N];

int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n; cin >> n;
    for (int i=1; i<=n; ++i) cin >> a[i];
    ll ans=0, res=0;
    for (ll bit=(1LL<<30); bit>=1; bit>>=1LL) {
        ll cnt1=0, cnt2=0;
        map<ll, ll> was0, was1;
        for (int i=1; i<=n; ++i) {
            if (a[i]&bit) {cnt2+=was0[was[i]], was1[was[i]]++; continue;}
            cnt1+=was1[was[i]], was0[was[i]]++;
        }
        ans+=min(cnt1, cnt2);
        if (cnt2 < cnt1) {
            res^=bit;
            for (int i=1; i<=n; ++i) a[i]^=bit;
        }
        for (int i=1; i<=n; ++i) if (a[i]&bit) was[i]^=bit;
    }
    cout << ans << " " << res;
}


#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;

//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;

//template<class T> using oset=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
//template<class T> using omultiset=tree<T,null_type,less_equal<T>,rb_tree_tag,tree_order_statistics_node_update>;

//find_by_order
//order_of_key

#define x first
#define y second
#define pb push_back
#define all(a) a.begin(),a.end()

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<pii> vii;
typedef vector<pll> vll;

mt19937 rnd(time(nullptr));

int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

}


#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;

//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;

//template<class T> using oset=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
//template<class T> using omultiset=tree<T,null_type,less_equal<T>,rb_tree_tag,tree_order_statistics_node_update>;

//find_by_order
//order_of_key

#define x first
#define y second
#define pb push_back
#define all(a) a.begin(),a.end()

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<pii> vii;
typedef vector<pll> vll;

mt19937 rnd(time(nullptr));

const int N=3e5+5;

int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n; cin >> n; vvi a(1, vi (n));
    for (int i=0; i<n; ++i) cin >> a[0][i];
    ll ans=0; int res=0;
    for (int bit=29; ~bit; --bit) {
        ll cnt0=0, cnt1=0; vvi b;
        int BIT=(1<<bit);
        for (auto v : a) {
            vi v0, v1;
            for (int val : v) {
                if (val&BIT) {
                    cnt1+=v0.size();
                    v1.pb(val);
                }
                else {
                    cnt0+=v1.size();
                    v0.pb(val);
                }
            }
            if (v0.size()) b.pb(v0);
            if (v1.size()) b.pb(v1);
        }
        ans+=min(cnt0, cnt1);
        if (cnt1 < cnt0) res+=BIT;
        a=b;
    }
    cout << ans << " " << res;
}


#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;

//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;

//template<class T> using oset=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
//template<class T> using omultiset=tree<T,null_type,less_equal<T>,rb_tree_tag,tree_order_statistics_node_update>;

//find_by_order
//order_of_key

#define x first
#define y second
#define pb push_back
#define all(a) a.begin(),a.end()

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<pii> vii;
typedef vector<pll> vll;

mt19937 rnd(time(nullptr));

int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n; cin >> n;
    vi a(n); for (int i=0; i<n; ++i) cin >> a[i];
    ll ans=0, cnt1=0, cnt2=0;
    int res=0;
    for (int bit=29; ~bit; --bit) {
        cnt1=cnt2=0;
        unordered_map<int, pii> cnt;
        for (int i=0; i<n; ++i) {
            if ((a[i]>>bit)&1) {
                cnt2+=(ll)cnt[(a[i]>>(bit+1))].x;
                cnt[(a[i]>>(bit+1))].y++;
                continue;
            }
            cnt1+=(ll)cnt[(a[i]>>(bit+1))].y;
            cnt[(a[i]>>(bit+1))].x++;
        }
        ans+=min(cnt1, cnt2);
        if (cnt2 < cnt1) res+=(1<<bit);
    }
    cout << ans << " " << res;
}


#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;

//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;

//template<class T> using oset=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
//template<class T> using omultiset=tree<T,null_type,less_equal<T>,rb_tree_tag,tree_order_statistics_node_update>;

//find_by_order
//order_of_key

#define x first
#define y second
#define pb push_back
#define all(a) a.begin(),a.end()

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<pii> vii;
typedef vector<pll> vll;

mt19937 rnd(time(nullptr));

int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n; cin >> n;
    vi a(n); for (int i=0; i<n; ++i) cin >> a[i];
    ll ans=0;
    int res=0;
    for (int bit=29; ~bit; --bit) {
        int BIT=(1<<bit);
        ll cnt1=0, cnt2=0;
        unordered_map<int, pii> cnt;
        for (auto val : a) {
            if (val&BIT) {
                cnt2+=cnt[val>>(bit+1)].x;
                cnt[val>>(bit+1)].y++;
            }
            else {
                cnt1+=cnt[val>>(bit+1)].y;
                cnt[val>>(bit+1)].x++;
            }
        }
        ans+=min(cnt1, cnt2);
        if (cnt2 < cnt1) res+=BIT;
    }
    cout << ans << " " << res;
}