#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define N 10005
#define PB push_back
#define sz(x) int(x.size())
#define F first
#define M ll(1e9 + 7)
#define S second
#define all(x) x.begin(), x.end()
#define endl '\n'

//#pragma GCC optimize("unroll-loops")
//#pragma GCC optimize("-O3")
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("fast-math")
//#pragma GCC optimize("no-stack-protector")

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef tree <int, null_type, less_equal <int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

ordered_set se;

ll mlt(ll x, ll y) {return (x * y) % M;}
ll sm(ll x, ll y) {return (x + y) % M;}

int n;

ll calc(vector <int> &a)
{
    se.clear();

    ll ans = 0;

    for (int i = 0; i < n; i++) {ans += i - se.order_of_key(a[i] + 1); se.insert(a[i]);}

    return ans;
}

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

    ////freopen("fcolor.in", "r", stdin); freopen("fcolor.out", "w", stdout);

    cin >> n;

    vector <int> a(n);

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

    ll ans = calc(a);

    int cur = 0;

    vector <int> b(n);

    for (int i = 29; i >= 0; i--)
    {
        cur |= (1 << i);

        for (int j = 0; j < n; j++) b[j] = (a[j] ^ cur);

        ll val = calc(b);

        if (val < ans) ans = val;
          else cur ^= (1 << i);

        if (ans == 0) break;
    }

    cout << ans << " " << cur << endl;
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define N 9001005
#define PB push_back
#define sz(x) int(x.size())
#define F first
#define M ll(1e9 + 7)
#define S second
#define all(x) x.begin(), x.end()
#define endl '\n'

//#pragma GCC optimize("unroll-loops")
//#pragma GCC optimize("-O3")
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("fast-math")
//#pragma GCC optimize("no-stack-protector")

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef tree <int, null_type, less_equal <int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

ordered_set se;

ll mlt(ll x, ll y) {return (x * y) % M;}
ll sm(ll x, ll y) {return (x + y) % M;}

int n, nxt[N][30], kol[N], id = 1, val, dob[30], j, sum[N];

ll calc(vector <int> &a)
{
    se.clear();

    ll sm = 0;

    for (int i = 0; i < n; i++) {sm += i - se.order_of_key(a[i] + 1); se.insert(a[i]);}

    return sm;
}

void add(int v)
{
    while (j >= 0 && !((1 << j) & val)) j--;

    for (int i = 0; i < j; i++) if (nxt[v][i] != 0) dob[j] -= sum[nxt[v][i]];

    dob[j] -= kol[v];

    for (int i = j + 1; i < 30; i++) if (nxt[v][i] != 0) dob[i] += sum[nxt[v][i]];

    if (j == -1) {sum[v]++; kol[v]++; return;}

    if (nxt[v][j] == 0) nxt[v][j] = id++;

    j--;

    add(nxt[v][j + 1]);

    sum[v]++;
}

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

    ////freopen("fcolor.in", "r", stdin); freopen("fcolor.out", "w", stdout);

    cin >> n;

    vector <int> a(n);

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

    int cur = 0;

    for (int i = 0; i < n; i++)
    {
        val = a[i];

        j = 29;

        add(0);
    }

    for (int i = 0; i < 30; i++) if (dob[i] > 0) cur |= (1 << i);

    for (int i = 0; i < n; i++) a[i] = (a[i] ^ cur);

    cout << calc(a) << " " << cur << endl;
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define N 1001005
#define PB push_back
#define sz(x) int(x.size())
#define F first
#define M ll(1e9 + 7)
#define S second
#define all(x) x.begin(), x.end()
#define endl '\n'

//#pragma GCC optimize("unroll-loops")
//#pragma GCC optimize("-O3")
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("fast-math")
//#pragma GCC optimize("no-stack-protector")

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef tree <int, null_type, less_equal <int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

ordered_set se;

ll mlt(ll x, ll y) {return (x * y) % M;}
ll sm(ll x, ll y) {return (x + y) % M;}

int n, nxt[N][30], kol[N], id = 1, val, dob[30], j, sum[N];

ll calc(vector <int> &a)
{
    se.clear();

    ll sm = 0;

    for (int i = 0; i < n; i++) {sm += i - se.order_of_key(a[i] + 1); se.insert(a[i]);}

    return sm;
}

void add(int v)
{
    while (j >= 0 && !((1 << j) & val)) j--;

    for (int i = 0; i < j; i++) if (nxt[v][i] != 0) dob[j] -= sum[nxt[v][i]];

    dob[j] -= kol[v];

    for (int i = j + 1; i < 30; i++) if (nxt[v][i] != 0) dob[i] += sum[nxt[v][i]];

    if (j == -1) {sum[v]++; kol[v]++; return;}

    if (nxt[v][j] == 0) nxt[v][j] = id++;

    j--;

    add(nxt[v][j + 1]);

    sum[v]++;
}

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

    ////freopen("fcolor.in", "r", stdin); freopen("fcolor.out", "w", stdout);

    cin >> n;

    vector <int> a(n);

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

    int cur = 0;

    for (int i = 0; i < n; i++)
    {
        val = a[i];

        j = 29;

        add(0);
    }

    for (int i = 0; i < 30; i++) if (dob[i] > 0) cur |= (1 << i);

    for (int i = 0; i < n; i++) a[i] = (a[i] ^ cur);

    cout << calc(a) << " " << cur << endl;
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define N 10005
#define PB push_back
#define sz(x) int(x.size())
#define F first
#define M ll(1e9 + 7)
#define S second
#define all(x) x.begin(), x.end()
#define endl '\n'

//#pragma GCC optimize("unroll-loops")
//#pragma GCC optimize("-O3")
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("fast-math")
//#pragma GCC optimize("no-stack-protector")

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef tree <int, null_type, less_equal <int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

ordered_set se;

ll mlt(ll x, ll y) {return (x * y) % M;}
ll sm(ll x, ll y) {return (x + y) % M;}

int n;

ll calc(vector <int> &a)
{
    se.clear();

    ll ans = 0;

    for (int i = 0; i < n; i++) {ans += i - se.order_of_key(a[i] + 1); se.insert(a[i]);}

    return ans;
}

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

    ////freopen("fcolor.in", "r", stdin); freopen("fcolor.out", "w", stdout);

    cin >> n;

    vector <int> a(n);

    int mx = 0;

    for (int i = 0; i < n; i++) {cin >> a[i]; mx = max(mx, a[i]);}

    ll ans = calc(a);

    int cur = 0;

    vector <int> b(n);

    for (int i = log2(mx); i >= 0; i--)
    {
        cur |= (1 << i);

        for (int j = 0; j < n; j++) b[j] = (a[j] ^ cur);

        ll val = calc(b);

        if (val < ans) ans = val;
          else cur ^= (1 << i);

        if (ans == 0) break;
    }

    cout << ans << " " << cur << endl;
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define N 10005
#define PB push_back
#define sz(x) int(x.size())
#define F first
#define M ll(1e9 + 7)
#define S second
#define all(x) x.begin(), x.end()
#define endl '\n'

//#pragma GCC optimize("unroll-loops")
//#pragma GCC optimize("-O3")
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("fast-math")
//#pragma GCC optimize("no-stack-protector")

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef tree <int, null_type, less_equal <int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

ordered_set se;

ll mlt(ll x, ll y) {return (x * y) % M;}
ll sm(ll x, ll y) {return (x + y) % M;}

int n;

ll calc(vector <int> &a)
{
    se.clear();

    ll ans = 0;

    for (int i = 0; i < n; i++) {ans += sz(se) - se.order_of_key(a[i] + 1); se.insert(a[i]);}

    return ans;
}

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

    ////freopen("fcolor.in", "r", stdin); freopen("fcolor.out", "w", stdout);

    cin >> n;

    vector <int> a(n);

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

    ll ans = calc(a), cur = 0;

    for (ll i = 30; i >= 0; i--)
    {
        vector <int> b = a;

        cur |= (1 << i);

        for (int j = 0; j < n; j++) b[j] = (b[j] ^ cur);

        ll val = calc(b);

        if (val < ans) ans = val;
          else cur ^= (1 << i);
    }

    cout << ans << " " << cur << endl;
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define N 301005
#define PB push_back
#define sz(x) int(x.size())
#define F first
#define M ll(1e9 + 7)
#define S second
#define all(x) x.begin(), x.end()
#define endl '\n'

//#pragma GCC optimize("unroll-loops")
//#pragma GCC optimize("-O3")
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("fast-math")
//#pragma GCC optimize("no-stack-protector")

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef tree <int, null_type, less_equal <int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

ordered_set se;

ll mlt(ll x, ll y) {return (x * y) % M;}
ll sm(ll x, ll y) {return (x + y) % M;}

int n, nxt[N][30], kol[N], id = 1, val, dob[30], j, sum[N];

ll calc(vector <int> &a)
{
    se.clear();

    ll sm = 0;

    for (int i = 0; i < n; i++) {sm += i - se.order_of_key(a[i] + 1); se.insert(a[i]);}

    return sm;
}

void add(int v)
{
    while (j >= 0 && !((1 << j) & val)) j--;

    if (j == -1) {sum[v]++; return;}

    for (int i = 0; i < j; i++) if (nxt[v][i] != 0) dob[i] -= sum[nxt[v][i]];

    for (int i = j + 1; i < 30; i++) if (nxt[v][i] != 0) dob[i] += sum[nxt[v][i]];

    if (nxt[v][j] == 0) nxt[v][j] = id++;

    j--;

    add(nxt[v][j + 1]);

    sum[v]++;
}

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

    ////freopen("fcolor.in", "r", stdin); freopen("fcolor.out", "w", stdout);

    cin >> n;

    vector <int> a(n);

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

    int cur = 0;

    for (int i = 0; i < n; i++)
    {
        val = a[i];

        j = 29;

        add(0);
    }

    for (int i = 0; i < 30; i++) if (dob[i] > 0) cur |= (1 << i);

    for (int i = 0; i < n; i++) a[i] = (a[i] ^ cur);

    cout << calc(a) << " " << cur << endl;
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define N 601005
#define PB push_back
#define sz(x) int(x.size())
#define F first
#define M ll(1e9 + 7)
#define S second
#define all(x) x.begin(), x.end()
#define endl '\n'

//#pragma GCC optimize("unroll-loops")
//#pragma GCC optimize("-O3")
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("fast-math")
//#pragma GCC optimize("no-stack-protector")

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef tree <int, null_type, less_equal <int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

ordered_set se;

ll mlt(ll x, ll y) {return (x * y) % M;}
ll sm(ll x, ll y) {return (x + y) % M;}

int n, nxt[N][30], kol[N], id = 1, val, dob[30], j, sum[N];

ll calc(vector <int> &a)
{
    se.clear();

    ll sm = 0;

    for (int i = 0; i < n; i++) {sm += i - se.order_of_key(a[i] + 1); se.insert(a[i]);}

    return sm;
}

void add(int v)
{
    while (j >= 0 && !((1 << j) & val)) j--;

    for (int i = 0; i < j; i++) if (nxt[v][i] != 0) dob[j] -= sum[nxt[v][i]];

    dob[j] -= kol[v];

    for (int i = j + 1; i < 30; i++) if (nxt[v][i] != 0) dob[i] += sum[nxt[v][i]];

    if (j == -1) {sum[v]++; kol[v]++; return;}

    if (nxt[v][j] == 0) nxt[v][j] = id++;

    j--;

    add(nxt[v][j + 1]);

    sum[v]++;
}

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

    ////freopen("fcolor.in", "r", stdin); freopen("fcolor.out", "w", stdout);

    cin >> n;

    vector <int> a(n);

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

    int cur = 0;

    for (int i = 0; i < n; i++)
    {
        val = a[i];

        j = 29;

        add(0);
    }

    for (int i = 0; i < 30; i++) if (dob[i] > 0) cur |= (1 << i);

    for (int i = 0; i < n; i++) a[i] = (a[i] ^ cur);

    cout << calc(a) << " " << cur << endl;
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define N 4001005
#define PB push_back
#define sz(x) int(x.size())
#define F first
#define M ll(1e9 + 7)
#define S second
#define all(x) x.begin(), x.end()
#define endl '\n'

//#pragma GCC optimize("unroll-loops")
//#pragma GCC optimize("-O3")
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("fast-math")
//#pragma GCC optimize("no-stack-protector")

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef tree <int, null_type, less_equal <int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

ordered_set se;

ll mlt(ll x, ll y) {return (x * y) % M;}
ll sm(ll x, ll y) {return (x + y) % M;}

int n, nxt[N][30], kol[N], id = 1, val, dob[30], j, sum[N];

ll calc(vector <int> &a)
{
    se.clear();

    ll sm = 0;

    for (int i = 0; i < n; i++) {sm += i - se.order_of_key(a[i] + 1); se.insert(a[i]);}

    return sm;
}

void add(int v)
{
    while (j >= 0 && !((1 << j) & val)) j--;

    for (int i = 0; i < j; i++) if (nxt[v][i] != 0) dob[j] -= sum[nxt[v][i]];

    dob[j] -= kol[v];

    for (int i = j + 1; i < 30; i++) if (nxt[v][i] != 0) dob[i] += sum[nxt[v][i]];

    if (j == -1) {sum[v]++; kol[v]++; return;}

    if (nxt[v][j] == 0) nxt[v][j] = id++;

    j--;

    add(nxt[v][j + 1]);

    sum[v]++;
}

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

    ////freopen("fcolor.in", "r", stdin); freopen("fcolor.out", "w", stdout);

    cin >> n;

    vector <int> a(n);

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

    int cur = 0;

    for (int i = 0; i < n; i++)
    {
        val = a[i];

        j = 29;

        add(0);
    }

    for (int i = 0; i < 30; i++) if (dob[i] > 0) cur |= (1 << i);

    for (int i = 0; i < n; i++) a[i] = (a[i] ^ cur);

    cout << calc(a) << " " << cur << endl;
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define N 3001005
#define PB push_back
#define sz(x) int(x.size())
#define F first
#define M ll(1e9 + 7)
#define S second
#define all(x) x.begin(), x.end()
#define endl '\n'

//#pragma GCC optimize("unroll-loops")
//#pragma GCC optimize("-O3")
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("fast-math")
//#pragma GCC optimize("no-stack-protector")

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef tree <int, null_type, less_equal <int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

ordered_set se;

ll mlt(ll x, ll y) {return (x * y) % M;}
ll sm(ll x, ll y) {return (x + y) % M;}

int n, nxt[N][30], kol[N], id = 1, val, dob[30], j, sum[N];

ll calc(vector <int> &a)
{
    se.clear();

    ll sm = 0;

    for (int i = 0; i < n; i++) {sm += i - se.order_of_key(a[i] + 1); se.insert(a[i]);}

    return sm;
}

void add(int v)
{
    while (j >= 0 && !((1 << j) & val)) j--;

    for (int i = 0; i < j; i++) if (nxt[v][i] != 0) dob[j] -= sum[nxt[v][i]];

    dob[j] -= kol[v];

    for (int i = j + 1; i < 30; i++) if (nxt[v][i] != 0) dob[i] += sum[nxt[v][i]];

    if (j == -1) {sum[v]++; kol[v]++; return;}

    if (nxt[v][j] == 0) nxt[v][j] = id++;

    j--;

    add(nxt[v][j + 1]);

    sum[v]++;
}

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

    ////freopen("fcolor.in", "r", stdin); freopen("fcolor.out", "w", stdout);

    cin >> n;

    vector <int> a(n);

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

    int cur = 0;

    for (int i = 0; i < n; i++)
    {
        val = a[i];

        j = 29;

        add(0);
    }

    for (int i = 0; i < 30; i++) if (dob[i] > 0) cur |= (1 << i);

    for (int i = 0; i < n; i++) a[i] = (a[i] ^ cur);

    cout << calc(a) << " " << cur << endl;
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define N 10005
#define PB push_back
#define sz(x) int(x.size())
#define F first
#define M ll(1e9 + 7)
#define S second
#define all(x) x.begin(), x.end()
#define endl '\n'

#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("-O3")
#pragma GCC optimize("Ofast")
//#pragma GCC optimize("fast-math")
//#pragma GCC optimize("no-stack-protector")

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef tree <int, null_type, less_equal <int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

ordered_set se;

ll mlt(ll x, ll y) {return (x * y) % M;}
ll sm(ll x, ll y) {return (x + y) % M;}

int n;

ll calc(vector <int> &a)
{
    se.clear();

    ll ans = 0;

    for (int i = 0; i < n; i++) {ans += sz(se) - se.order_of_key(a[i] + 1); se.insert(a[i]);}

    return ans;
}

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

    ////freopen("fcolor.in", "r", stdin); freopen("fcolor.out", "w", stdout);

    cin >> n;

    vector <int> a(n);

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

    ll ans = calc(a), cur = 0;

    vector <int> b(n);

    for (ll i = 30; i >= 0; i--)
    {
        cur |= (1 << i);

        for (int j = 0; j < n; j++) b[j] = (a[j] ^ cur);

        ll val = calc(b);

        if (val < ans) ans = val;
          else cur ^= (1 << i);
    }

    cout << ans << " " << cur << endl;
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define N 301005
#define PB push_back
#define sz(x) int(x.size())
#define F first
#define M ll(1e9 + 7)
#define S second
#define all(x) x.begin(), x.end()
#define endl '\n'

//#pragma GCC optimize("unroll-loops")
//#pragma GCC optimize("-O3")
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("fast-math")
//#pragma GCC optimize("no-stack-protector")

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef tree <int, null_type, less_equal <int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

ordered_set se;

ll mlt(ll x, ll y) {return (x * y) % M;}
ll sm(ll x, ll y) {return (x + y) % M;}

int n, nxt[N][30], kol[N], id = 1, val, dob[30], j, sum[N];

ll calc(vector <int> &a)
{
    se.clear();

    ll sm = 0;

    for (int i = 0; i < n; i++) {sm += i - se.order_of_key(a[i] + 1); se.insert(a[i]);}

    return sm;
}

void add(int v)
{
    while (j >= 0 && !((1 << j) & val)) j--;

    for (int i = 0; i < j; i++) if (nxt[v][i] != 0) dob[j] -= sum[nxt[v][i]];

    dob[j] -= kol[v];

    for (int i = j + 1; i < 30; i++) if (nxt[v][i] != 0) dob[i] += sum[nxt[v][i]];

    if (j == -1) {sum[v]++; kol[v]++; return;}

    if (nxt[v][j] == 0) nxt[v][j] = id++;

    j--;

    add(nxt[v][j + 1]);

    sum[v]++;
}

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

    ////freopen("fcolor.in", "r", stdin); freopen("fcolor.out", "w", stdout);

    cin >> n;

    vector <int> a(n);

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

    int cur = 0;

    for (int i = 0; i < n; i++)
    {
        val = a[i];

        j = 29;

        add(0);
    }

    for (int i = 0; i < 30; i++) if (dob[i] > 0) cur |= (1 << i);

    for (int i = 0; i < n; i++) a[i] = (a[i] ^ cur);

    cout << calc(a) << " " << cur << endl;
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define N 10005
#define PB push_back
#define sz(x) int(x.size())
#define F first
#define M ll(1e9 + 7)
#define S second
#define all(x) x.begin(), x.end()
#define endl '\n'

//#pragma GCC optimize("unroll-loops")
//#pragma GCC optimize("-O3")
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("fast-math")
//#pragma GCC optimize("no-stack-protector")

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef tree <int, null_type, less_equal <int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

ordered_set se;

ll mlt(ll x, ll y) {return (x * y) % M;}
ll sm(ll x, ll y) {return (x + y) % M;}

int n;

ll ans;

ll calc(vector <int> &a)
{
    se.clear();

    ll sm = 0;

    for (int i = 0; i < n; i++) {sm += i - se.order_of_key(a[i] + 1); se.insert(a[i]);}

    return sm;
}

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

    ////freopen("fcolor.in", "r", stdin); freopen("fcolor.out", "w", stdout);

    cin >> n;

    vector <int> a(n);

    int mx = 0, all = 0;

    for (int i = 0; i < n; i++) {cin >> a[i]; mx = max(mx, a[i]); all |= (1 << i);}

    ans = calc(a);

    int cur = 0;

    vector <int> b(n);

    for (int i = log2(mx); i >= 0; i--)
    {
        if (!((1 << i) & all) continue;

        cur |= (1 << i);

        se.clear();

        ll val = 0;

        for (int j = 0; j < n; j++) {b[j] = (a[j] ^ cur); val += j - se.order_of_key(b[j] + 1); se.insert(b[j]);}

        if (val < ans) ans = val;
          else cur ^= (1 << i);

        if (ans == 0) break;
    }

    cout << ans << " " << cur << endl;
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define N 301005
#define PB push_back
#define sz(x) int(x.size())
#define F first
#define M ll(1e9 + 7)
#define S second
#define all(x) x.begin(), x.end()
#define endl '\n'

//#pragma GCC optimize("unroll-loops")
//#pragma GCC optimize("-O3")
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("fast-math")
//#pragma GCC optimize("no-stack-protector")

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef tree <int, null_type, less_equal <int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

ordered_set se;

ll mlt(ll x, ll y) {return (x * y) % M;}
ll sm(ll x, ll y) {return (x + y) % M;}

int n, nxt[N][30], kol[N], id = 1, val, dob[30], j, sum[N];

ll calc(vector <int> &a)
{
    se.clear();

    ll sm = 0;

    for (int i = 0; i < n; i++) {sm += i - se.order_of_key(a[i] + 1); se.insert(a[i]);}

    return sm;
}

void add(int v)
{
    while (j >= 0 && !((1 << j) & val)) j--;

    if (j == -1) {sum[v]++; return;}

    for (int i = 0; i < j; i++) if (nxt[v][i] != 0) dob[j] -= sum[nxt[v][i]];

    for (int i = j + 1; i < 30; i++) if (nxt[v][i] != 0) dob[i] += sum[nxt[v][i]];

    if (nxt[v][j] == 0) nxt[v][j] = id++;

    j--;

    add(nxt[v][j + 1]);

    sum[v]++;
}

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

    ////freopen("fcolor.in", "r", stdin); freopen("fcolor.out", "w", stdout);

    cin >> n;

    vector <int> a(n);

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

    int cur = 0;

    for (int i = 0; i < n; i++)
    {
        val = a[i];

        j = 29;

        add(0);
    }

    for (int i = 0; i < 30; i++) if (dob[i] > 0) cur |= (1 << i);

    for (int i = 0; i < n; i++) a[i] = (a[i] ^ cur);

    cout << calc(a) << " " << cur << endl;
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define N 301005
#define PB push_back
#define sz(x) int(x.size())
#define F first
#define M ll(1e9 + 7)
#define S second
#define all(x) x.begin(), x.end()
#define endl '\n'

//#pragma GCC optimize("unroll-loops")
//#pragma GCC optimize("-O3")
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("fast-math")
//#pragma GCC optimize("no-stack-protector")

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef tree <int, null_type, less_equal <int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

ordered_set se;

ll mlt(ll x, ll y) {return (x * y) % M;}
ll sm(ll x, ll y) {return (x + y) % M;}

int n, nxt[N][30], kol[N], id = 1, val, dob[30], j, sum[N];

ll calc(vector <int> &a)
{
    se.clear();

    ll sm = 0;

    for (int i = 0; i < n; i++) {sm += i - se.order_of_key(a[i] + 1); se.insert(a[i]);}

    return sm;
}

void add(int v)
{
    while (j >= 0 && !((1 << j) & val)) j--;

    for (int i = 0; i < j; i++) if (nxt[v][i] != 0) dob[j] -= sum[nxt[v][i]];

    for (int i = j + 1; i < 30; i++) if (nxt[v][i] != 0) dob[i] += sum[nxt[v][i]];

    if (j == -1) {sum[v]++; return;}

    if (nxt[v][j] == 0) nxt[v][j] = id++;

    j--;

    add(nxt[v][j + 1]);

    sum[v]++;
}

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

    ////freopen("fcolor.in", "r", stdin); freopen("fcolor.out", "w", stdout);

    cin >> n;

    vector <int> a(n);

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

    int cur = 0;

    for (int i = 0; i < n; i++)
    {
        val = a[i];

        j = 29;

        add(0);
    }

    for (int i = 0; i < 30; i++) if (dob[i] > 0) cur |= (1 << i);

    for (int i = 0; i < n; i++) a[i] = (a[i] ^ cur);

    cout << calc(a) << " " << cur << endl;
}


#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>

#define N 300005
#define PB push_back
#define sz(x) int(x.size())
#define F first
#define M ll(1e9 + 7)
#define S second
#define all(x) x.begin(), x.end()
#define endl '\n'

//#pragma GCC optimize("unroll-loops")
//#pragma GCC optimize("-O3")
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("fast-math")
//#pragma GCC optimize("no-stack-protector")

using namespace std;
//using namespace __gnu_pbds;

typedef long long ll;
//typedef tree <int, null_type, less_equal <int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

//ordered_set se;

ll mlt(ll x, ll y) {return (x * y) % M;}
ll sm(ll x, ll y) {return (x + y) % M;}

int n, t[N];

void upd(int v) {for (; v < N; v = (v | (v + 1))) t[v]++;}
int get(int v) {int sm = 0; for (; v >= 0; v = (v & (v + 1)) - 1) sm += t[v]; return sm;}

ll calc(vector <int> &a)
{
    memset(t, 0, sizeof(t));

    ll ans = 0;

    for (int i = 0; i < n; i++) {ans += i - get(a[i]); upd(a[i]);}

    return ans;
}

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

    ////freopen("fcolor.in", "r", stdin); freopen("fcolor.out", "w", stdout);

    cin >> n;

    vector <int> a(n);

    int mx = 0;

    for (int i = 0; i < n; i++) {cin >> a[i]; mx = max(mx, a[i]);}

    ll ans = calc(a);

    int cur = 0;

    vector <int> b(n);

    for (register int i = log2(mx); i >= 0; i--)
    {
        cur |= (1 << i);

        for (register int j = 0; j < n; j++) b[j] = (a[j] ^ cur);

        ll val = calc(b);

        if (val < ans) ans = val;
          else cur ^= (1 << i);

        if (ans == 0) break;
    }

    cout << ans << " " << cur << endl;
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define N 10005
#define PB push_back
#define sz(x) int(x.size())
#define F first
#define M ll(1e9 + 7)
#define S second
#define all(x) x.begin(), x.end()
#define endl '\n'

//#pragma GCC optimize("unroll-loops")
//#pragma GCC optimize("-O3")
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("fast-math")
//#pragma GCC optimize("no-stack-protector")

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef tree <int, null_type, less_equal <int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

ordered_set se;

ll mlt(ll x, ll y) {return (x * y) % M;}
ll sm(ll x, ll y) {return (x + y) % M;}

int n;

ll ans;

ll calc(vector <int> &a)
{
    se.clear();

    ll sm = 0;

    for (int i = 0; i < n; i++) {sm += i - se.order_of_key(a[i] + 1); se.insert(a[i]);}

    return sm;
}

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

    ////freopen("fcolor.in", "r", stdin); freopen("fcolor.out", "w", stdout);

    cin >> n;

    vector <int> a(n);

    int mx = 0;

    for (int i = 0; i < n; i++) {cin >> a[i]; mx = max(mx, a[i]);}

    ans = calc(a);

    int cur = 0;

    vector <int> b(n);

    for (int i = log2(mx); i >= 0; i--)
    {
        cur |= (1 << i);

        se.clear();

        ll val = 0;

        for (int j = 0; j < n; j++) {b[j] = (a[j] ^ cur); val += j - se.order_of_key(b[j] + 1); se.insert(b[j]);}

        if (val < ans) ans = val;
          else cur ^= (1 << i);

        if (ans == 0) break;
    }

    cout << ans << " " << cur << endl;
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define N 3001005
#define PB push_back
#define sz(x) int(x.size())
#define F first
#define M ll(1e9 + 7)
#define S second
#define all(x) x.begin(), x.end()
#define endl '\n'

//#pragma GCC optimize("unroll-loops")
//#pragma GCC optimize("-O3")
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("fast-math")
//#pragma GCC optimize("no-stack-protector")

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef tree <int, null_type, less_equal <int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

ordered_set se;

ll mlt(ll x, ll y) {return (x * y) % M;}
ll sm(ll x, ll y) {return (x + y) % M;}

int n, nxt[N][30], kol[N], id = 1, val, j, sum[N];

ll dob[30];

ll calc(vector <int> &a)
{
    se.clear();

    ll sm = 0;

    for (int i = 0; i < n; i++) {sm += i - se.order_of_key(a[i] + 1); se.insert(a[i]);}

    return sm;
}

void add(int v)
{
    while (j >= 0 && !((1 << j) & val)) j--;

    for (int i = 0; i < j; i++) if (nxt[v][i] != 0) dob[j] -= sum[nxt[v][i]];

    dob[j] -= kol[v];

    for (int i = j + 1; i < 30; i++) if (nxt[v][i] != 0) dob[i] += sum[nxt[v][i]];

    if (j == -1) {sum[v]++; kol[v]++; return;}

    if (nxt[v][j] == 0) nxt[v][j] = id++;

    j--;

    add(nxt[v][j + 1]);

    sum[v]++;
}

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

    ////freopen("fcolor.in", "r", stdin); freopen("fcolor.out", "w", stdout);

    cin >> n;

    vector <int> a(n);

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

    int cur = 0;

    for (int i = 0; i < n; i++)
    {
        val = a[i];

        j = 29;

        add(0);
    }

    for (int i = 0; i < 30; i++) if (dob[i] > 0) cur |= (1 << i);

    for (int i = 0; i < n; i++) a[i] = (a[i] ^ cur);

    cout << calc(a) << " " << cur << endl;
}


#include <bits/stdc++.h>
#define int long long
#define ld long double
#define y1 goerohgerigegoihr
#define y0 peowjfefwepojfewe

using namespace std;

int n, a[300005], ans;
long long k;

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

    cin >> n;

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

    for(int i = 0; i < 30; i++)
    {
        int x = (1 << i);
        int l = 0, r = 0;

        if(i < 12)
        {
            map <int32_t, int32_t> m;

            for(int j = 0; j < n; j++)
            {
                int y = a[j] / x;
                m[y]++;

                if((y & 1) == 0)
                    l += m[y + 1];
                else r += m[y - 1];
            }

            if(r < l)
                ans += x;

            k += 1ll * min(l, r);
        }
        else
        {
            int m[1000005];

            for(int j = 0; j < n; j++)
            {
                int y = a[j] / x;
                m[y]++;

                if(abs(m[(y ^ 1)]) > 300005)
                    m[(y ^ 1)] = 0;

                if((y & 1) == 0)
                    l += m[y + 1];
                else r += m[y - 1];
            }

            if(r < l)
                ans += x;

            k += 1ll * min(l, r);
        }

    }

    cout << k << ' ' << ans;
}


#include <bits/stdc++.h>
//#define int long long
#define ld long double
#define y1 goerohgerigegoihr
#define y0 peowjfefwepojfewe

using namespace std;

int n, a[300005], ans, m[10000005];
long long k;

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

    cin >> n;

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

    for(int i = 0; i < 30; i++)
    {
        int x = (1 << i);
        int l = 0, r = 0;

        if(i < 8)
        {
            map <int32_t, int32_t> m;

            for(int j = 0; j < n; j++)
            {
                int y = a[j] / x;
                m[y]++;

                if((y & 1) == 0)
                    l += m[y + 1];
                else r += m[y - 1];
            }

            if(r < l)
                ans += x;

            k += 1ll * min(l, r);
        }
        else
        {
            for(int j = 0; j < n; j++)
            {
                int y = a[j] / x;

                m[y]++;

                if((y & 1) == 0)
                    l += m[y + 1];
                else r += m[y - 1];
            }

            if(r < l)
                ans += x;

            k += 1ll * min(l, r);

            for(int j = 0; j < n; j++)
            {
                int y = a[j] / x;
                m[y] = 0;
            }
        }

    }

    cout << k << ' ' << ans;
}


#include <bits/stdc++.h>
#define int long long
#define ld long double
#define y1 goerohgerigegoihr
#define y0 peowjfefwepojfewe

using namespace std;

int n, a[300005], ans;
long long k;

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

    cin >> n;

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

    for(int i = 0; i < 30; i++)
    {
        int x = (1 << i);
        int l = 0, r = 0;

        if(i < 20)
        {
            map <int32_t, int32_t> m;

            for(int j = 0; j < n; j++)
            {
                int y = a[j] / x;
                m[y]++;

                if((y & 1) == 0)
                    l += m[y + 1];
                else r += m[y - 1];
            }

            if(r < l)
                ans += x;

            k += 1ll * min(l, r);
        }
        else
        {
            int m[1000005];

            for(int j = 0; j < n; j++)
            {
                int y = a[j] / x;
                m[y]++;

                if(abs(m[(y ^ 1)]) > 300005)
                    m[(y ^ 1)] = 0;

                if((y & 1) == 0)
                    l += m[y + 1];
                else r += m[y - 1];
            }

            if(r < l)
                ans += x;

            k += 1ll * min(l, r);
        }

    }

    cout << k << ' ' << ans;
}


#include <bits/stdc++.h>
//#define int long long
#define ld long double
#define y1 goerohgerigegoihr
#define y0 peowjfefwepojfewe

using namespace std;

int n, a[300005], ans;
long long k;

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

    cin >> n;

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

    for(int i = 0; i < 30; i++)
    {
        int x = (1 << i);
        int l = 0, r = 0;

        if(i < 11)
        {
            map <int, int> m;

            for(int j = 0; j < n; j++)
            {
                int y = a[j] / x;
                m[y]++;

                if((y & 1) == 0)
                    l += m[y + 1];
                else r += m[y - 1];
            }

            if(r < l)
                ans += x;

            k += 1ll * min(l, r);
        }
        else
        {
            int m[1000005];

            for(int j = 0; j < n; j++)
            {
                int y = a[j] / x;
                m[y]++;

                if(abs(m[(y ^ 1)]) > 300005)
                    m[(y ^ 1)] = 0;

                if((y & 1) == 0)
                    l += m[y + 1];
                else r += m[y - 1];
            }

            if(r < l)
                ans += x;

            k += 1ll * min(l, r);
        }

    }

    cout << k << ' ' << ans;
}


#include <bits/stdc++.h>
#define int long long
#define ld long double
#define y1 goerohgerigegoihr
#define y0 peowjfefwepojfewe

using namespace std;

int n, a[300005], ans;
long long k;

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

    cin >> n;

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

    for(int i = 0; i < 30; i++)
    {
        int x = (1 << i);
        int l = 0, r = 0;

        if(i < 12)
        {
            map <int32_t, int32_t> m;

            for(int j = 0; j < n; j++)
            {
                int y = a[j] / x;
                m[y]++;

                if((y & 1) == 0)
                    l += m[y + 1];
                else r += m[y - 1];
            }

            if(r < l)
                ans += x;

            k += 1ll * min(l, r);
        }
        else
        {
            int m[1000005];

            for(int j = 0; j < n; j++)
            {
                int y = a[j] / x;

                if(abs(m[y]) > 300005)
                    m[y] = 0;

                m[y]++;

                if(abs(m[(y ^ 1)]) > 300005)
                    m[(y ^ 1)] = 0;

                if((y & 1) == 0)
                    l += m[y + 1];
                else r += m[y - 1];
            }

            if(r < l)
                ans += x;

            k += 1ll * min(l, r);
        }

    }

    cout << k << ' ' << ans;
}


#include <bits/stdc++.h>
#define int long long
#define ld long double
#define y1 goerohgerigegoihr
#define y0 peowjfefwepojfewe

using namespace std;

int n, a[300005], ans, m[1000005];
long long k;

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

    cin >> n;

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

    for(int i = 0; i < 30; i++)
    {
        int x = (1 << i);
        int l = 0, r = 0;

        if(i < 20)
        {
            map <int32_t, int32_t> m;

            for(int j = 0; j < n; j++)
            {
                int y = a[j] / x;
                m[y]++;

                if((y & 1) == 0)
                    l += m[y + 1];
                else r += m[y - 1];
            }

            if(r < l)
                ans += x;

            k += 1ll * min(l, r);
        }
        else
        {
            for(int j = 0; j < n; j++)
            {
                int y = a[j] / x;

                m[y]++;

                if((y & 1) == 0)
                    l += m[y + 1];
                else r += m[y - 1];
            }

            if(r < l)
                ans += x;

            k += 1ll * min(l, r);

            for(int j = 0; j < n; j++)
            {
                int y = a[j] / x;
                m[y] = 0;
            }
        }

    }

    cout << k << ' ' << ans;
}


#include <bits/stdc++.h>
#define int long long
#define ld long double
#define y1 goerohgerigegoihr
#define y0 peowjfefwepojfewe

using namespace std;

int n, a[300005], ans;
long long k;

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

    cin >> n;

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

    for(int i = 0; i < 30; i++)
    {
        int x = (1 << i);
        int l = 0, r = 0;

        if(i < 20)
        {
            map <int32_t, int32_t> m;

            for(int j = 0; j < n; j++)
            {
                int y = a[j] / x;
                m[y]++;

                if((y & 1) == 0)
                    l += m[y + 1];
                else r += m[y - 1];
            }

            if(r < l)
                ans += x;

            k += 1ll * min(l, r);
        }
        else
        {
            int m[100005];

            for(int j = 0; j < n; j++)
            {
                int y = a[j] / x;

                if(abs(m[y]) > 300005)
                    m[y] = 0;

                m[y]++;

                if(abs(m[(y ^ 1)]) > 300005)
                    m[(y ^ 1)] = 0;

                if((y & 1) == 0)
                    l += m[y + 1];
                else r += m[y - 1];
            }

            if(r < l)
                ans += x;

            k += 1ll * min(l, r);

            for(int j = 0; j < n; j++)
            {
                int y = a[j] / x;
                m[y] = 0;
            }
        }

    }

    cout << k << ' ' << ans;
}


#include <bits/stdc++.h>
#define int long long
#define ld long double
#define y1 goerohgerigegoihr
#define y0 peowjfefwepojfewe

using namespace std;

int n, a[300005], ans, m[50000005];
long long k;

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

    cin >> n;

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

    for(int i = 0; i < 30; i++)
    {
        int x = (1 << i);
        int l = 0, r = 0;

        if(i < 6)
        {
            map <int32_t, int32_t> m;

            for(int j = 0; j < n; j++)
            {
                int y = a[j] / x;
                m[y]++;

                if((y & 1) == 0)
                    l += m[y + 1];
                else r += m[y - 1];
            }

            if(r < l)
                ans += x;

            k += 1ll * min(l, r);
        }
        else
        {
            for(int j = 0; j < n; j++)
            {
                int y = a[j] / x;

                m[y]++;

                if((y & 1) == 0)
                    l += m[y + 1];
                else r += m[y - 1];
            }

            if(r < l)
                ans += x;

            k += 1ll * min(l, r);

            for(int j = 0; j < n; j++)
            {
                int y = a[j] / x;
                m[y] = 0;
            }
        }

    }

    cout << k << ' ' << ans;
}


#include <bits/stdc++.h>
#define int long long
#define ld long double
#define y1 goerohgerigegoihr
#define y0 peowjfefwepojfewe

using namespace std;

int n, a[300005], ans, m[10000005];
long long k;

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

    cin >> n;

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

    for(int i = 0; i < 30; i++)
    {
        int x = (1 << i);
        int l = 0, r = 0;

        if(i < 8)
        {
            map <int32_t, int32_t> m;

            for(int j = 0; j < n; j++)
            {
                int y = a[j] / x;
                m[y]++;

                if((y & 1) == 0)
                    l += m[y + 1];
                else r += m[y - 1];
            }

            if(r < l)
                ans += x;

            k += 1ll * min(l, r);
        }
        else
        {
            for(int j = 0; j < n; j++)
            {
                int y = a[j] / x;

                m[y]++;

                if((y & 1) == 0)
                    l += m[y + 1];
                else r += m[y - 1];
            }

            if(r < l)
                ans += x;

            k += 1ll * min(l, r);

            for(int j = 0; j < n; j++)
            {
                int y = a[j] / x;
                m[y] = 0;
            }
        }

    }

    cout << k << ' ' << ans;
}


#include <bits/stdc++.h>
//#define int long long
#define ld long double
#define y1 goerohgerigegoihr
#define y0 peowjfefwepojfewe

using namespace std;

int n, a[300005], ans, k;

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

    cin >> n;

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

    for(int i = 0; i < 30; i++)
    {
        int x = (1 << i);
        int l = 0, r = 0;

        map <int, int> m;

        for(int j = 0; j < n; j++)
        {
            int y = a[j] / x;
            m[y]++;

            if(y % 2 == 0)
                l += m[y + 1];
            else r += m[y - 1];
        }

        if(r < l)
            ans += x;

        k += min(l, r);
    }

    cout << k << ' ' << ans;
}


#include <bits/stdc++.h>
//#define int long long
#define ld long double
#define y1 goerohgerigegoihr
#define y0 peowjfefwepojfewe

using namespace std;

int n, a[300005], ans;
long long k;

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

    cin >> n;

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

    for(int i = 0; i < 30; i++)
    {
        int x = (1 << i);
        int l = 0, r = 0;

        map <int, int> m;

        for(int j = 0; j < n; j++)
        {
            int y = a[j] / x;
            m[y]++;

            if((y & 1) == 0)
                l += m[y + 1];
            else r += m[y - 1];
        }

        if(r < l)
            ans += x;

        k += 1ll * min(l, r);
    }

    cout << k << ' ' << ans;
}


#include <bits/stdc++.h>
#define int long long
#define ld long double
#define y1 goerohgerigegoihr
#define y0 peowjfefwepojfewe

using namespace std;

int n, a[300005], ans;
long long k;

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

    cin >> n;

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

    for(int i = 0; i < 30; i++)
    {
        int x = (1 << i);
        int l = 0, r = 0;

        if(i < 12)
        {
            map <int32_t, int32_t> m;

            for(int j = 0; j < n; j++)
            {
                int y = a[j] / x;
                m[y]++;

                if((y & 1) == 0)
                    l += m[y + 1];
                else r += m[y - 1];
            }

            if(r < l)
                ans += x;

            k += 1ll * min(l, r);
        }
        else
        {
            int m[1000005];

            for(int j = 0; j < n; j++)
            {
                int y = a[j] / x;

                if(abs(m[y]) > 300005)
                    m[y] = 0;

                m[y]++;

                if(abs(m[(y ^ 1)]) > 300005)
                    m[(y ^ 1)] = 0;

                if((y & 1) == 0)
                    l += m[y + 1];
                else r += m[y - 1];
            }

            if(r < l)
                ans += x;

            k += 1ll * min(l, r);

            for(int j = 0; j < n; j++)
            {
                int y = a[j] / x;
                m[y] = 0;
            }
        }

    }

    cout << k << ' ' << ans;
}


#include <bits/stdc++.h>

using namespace std;

#pragma GCC target("avx2")

unordered_map<int, vector<int>> t[30];

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; ++i)
    {
        cin >> a[i];
    }
    int ans = 0;
    for (int i = 0; i < n; ++i)
    {
        t[29][0].push_back(i);
    }
    long long cc = 0;
    for (int i = 29; i >= 0; --i)
    {
        long long cnt1 = 0;
        long long cnt0 = 0;
        for (auto el : t[i])
        {
            int c0 = 0;
            int c1 = 0;
            for (auto e : el.second)
            {
                if (a[e] & (1 << i))
                {
                    cnt1 += c0;
                    ++c1;
                }
                else
                {
                    cnt0 += c1;
                    ++c0;
                }
            }
        }
        if (i != 0)
        {
            for (int j = 0; j < n; ++j)
            {
                t[i - 1][(a[j] >> i) << i].push_back(j);
            }
        }
        if (cnt1 < cnt0)
        {
            ans |= (1 << i);
        }
        cc += (long long)min(cnt0, cnt1);
    }
    cout << cc << " " << ans << endl;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

unordered_map<int, vector<int>> t[31];

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; ++i)
    {
        cin >> a[i];
    }
    int ans = 0;
    for (int i = 0; i < n; ++i)
    {
        t[30][0].push_back(i);
    }
    long long cc = 0;
    for (int i = 29; i >= 0; --i)
    {
        int cnt1 = 0;
        int cnt0 = 0;
        for (auto el : t[i + 1])
        {
            int c0 = 0;
            int c1 = 0;
            for (auto e : el.second)
            {
                if (a[e] & (1 << i))
                {
                    cnt1 += c0;
                    ++c1;
                }
                else
                {
                    cnt0 += c1;
                    ++c0;
                }
            }
        }
        for (int j = 0; j < n; ++j)
        {
            t[i][(a[j] >> i) << i].push_back(j);
        }
        if (cnt1 < cnt0)
        {
            ans |= (1 << i);
        }
        cc += (long long)min(cnt0, cnt1);
    }
    cout << cc << " " << ans << endl;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

#pragma GCC target("avx2")

unordered_map<int, vector<int>> t;

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; ++i)
    {
        cin >> a[i];
    }
    int ans = 0;
    for (int i = 0; i < n; ++i)
    {
        t[0].push_back(i);
    }
    long long cc = 0;
    for (int i = 29; i >= 0; --i)
    {
        long long cnt1 = 0;
        long long cnt0 = 0;
        for (auto el : t)
        {
            int c0 = 0;
            int c1 = 0;
            for (auto e : el.second)
            {
                if (a[e] & (1 << i))
                {
                    cnt1 += c0;
                    ++c1;
                }
                else
                {
                    cnt0 += c1;
                    ++c0;
                }
            }
        }
        if (i != 0)
        {
            for (int j = 0; j < n; ++j)
            {
                t[(a[j] >> i) << i].push_back(j);
            }
        }
        if (cnt1 < cnt0)
        {
            ans |= (1 << i);
        }
        cc += (long long)min(cnt0, cnt1);
    }
    cout << cc << " " << ans << endl;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

unordered_map<int, vector<int>> t[31];

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; ++i)
    {
        cin >> a[i];
    }
    int ans = 0;
    for (int i = 0; i < n; ++i)
    {
        t[30][0].push_back(i);
    }
    int cc = 0;
    for (int i = 29; i >= 0; --i)
    {
        int cnt1 = 0;
        int cnt0 = 0;
        for (auto el : t[i + 1])
        {
            int c0 = 0;
            int c1 = 0;
            for (auto e : el.second)
            {
                if (a[e] & (1 << i))
                {
                    cnt1 += c0;
                    ++c1;
                }
                else
                {
                    cnt0 += c1;
                    ++c0;
                }
            }
        }
        for (int j = 0; j < n; ++j)
        {
            t[i][(a[j] >> i) << i].push_back(j);
        }
        if (cnt1 < cnt0)
        {
            ans |= (1 << i);
        }
        cc += min(cnt0, cnt1);
    }
    cout << cc << " " << ans << endl;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define int long long

unordered_map<int, vector<int>> t[31];

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; ++i)
    {
        cin >> a[i];
    }
    int ans = 0;
    for (int i = 0; i < n; ++i)
    {
        t[30][0].push_back(i);
    }
    int cc = 0;
    for (int i = 29; i >= 0; --i)
    {
        int cnt1 = 0;
        int cnt0 = 0;
        for (auto el : t[i + 1])
        {
            int c0 = 0;
            int c1 = 0;
            for (auto e : el.second)
            {
                if (a[e] & (1 << i))
                {
                    cnt1 += c0;
                    ++c1;
                }
                else
                {
                    cnt0 += c1;
                    ++c0;
                }
            }
        }
        for (int j = 0; j < n; ++j)
        {
            t[i][(a[j] >> i) << i].push_back(j);
        }
        if (cnt1 < cnt0)
        {
            ans |= (1 << i);
        }
        cc += min(cnt0, cnt1);
    }
    cout << cc << " " << ans << endl;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

#pragma GCC target("avx2")
#pragma GCC optimize("Ofast")

unordered_map<int, vector<int>> t[31];

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; ++i)
    {
        cin >> a[i];
    }
    int ans = 0;
    for (int i = 0; i < n; ++i)
    {
        t[30][0].push_back(i);
    }
    long long cc = 0;
    for (int i = 29; i >= 0; --i)
    {
        long long cnt1 = 0;
        long long cnt0 = 0;
        for (auto el : t[i + 1])
        {
            int c0 = 0;
            int c1 = 0;
            for (auto e : el.second)
            {
                if (a[e] & (1 << i))
                {
                    cnt1 += c0;
                    ++c1;
                }
                else
                {
                    cnt0 += c1;
                    ++c0;
                }
            }
        }
        for (int j = 0; j < n; ++j)
        {
            t[i][(a[j] >> i) << i].push_back(j);
        }
        if (cnt1 < cnt0)
        {
            ans |= (1 << i);
        }
        cc += (long long)min(cnt0, cnt1);
    }
    cout << cc << " " << ans << endl;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

#pragma GCC target("avx2")

unordered_map<int, vector<int>> t;

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; ++i)
    {
        cin >> a[i];
    }
    int ans = 0;
    for (int i = 0; i < n; ++i)
    {
        t[0].push_back(i);
    }
    long long cc = 0;
    for (int i = 29; i >= 0; --i)
    {
        long long cnt1 = 0;
        long long cnt0 = 0;
        for (auto el : t)
        {
            int c0 = 0;
            int c1 = 0;
            for (auto e : el.second)
            {
                if (a[e] & (1 << i))
                {
                    cnt1 += c0;
                    ++c1;
                }
                else
                {
                    cnt0 += c1;
                    ++c0;
                }
            }
        }
        if (i != 0)
        {
            t = {};
            for (int j = 0; j < n; ++j)
            {
                t[(a[j] >> i) << i].push_back(j);
            }
        }
        if (cnt1 < cnt0)
        {
            ans |= (1 << i);
        }
        cc += (long long)min(cnt0, cnt1);
    }
    cout << cc << " " << ans << endl;
    return 0;
}


#include <bits/stdc++.h>
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
using namespace std;

typedef long long ll;
typedef unsigned long long llu;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<int, pii> piii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef pair<string, int> psi;
typedef pair<char, int> pci;
typedef pair<int, char> pic;
const int MOD = 1e9 + 7;
const long double PI = 3.141592653589793238462643383279502884197;

ll fac[1] = {1}, inv[1] = {1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll mp(ll a,ll b){ll ret=1;while(b){if(b&1)ret=ret*a%MOD;a=a*a%MOD;b>>=1;}return ret;}
ll cmb(ll r, ll c) {return (c>r||c<0) ? 0:fac[r] * inv[c] % MOD * inv[r - c] % MOD;}

int n, ans = 0, mav = 0;
int a[300000];
unordered_map<int, int> ca, cb;

void cal(int bit) {
    ca.clear(), cb.clear();
    int mask = bit - 1;
    mask = ~mask;

    int at = ans, bt = ans | bit, x, y;
    ll ac = 0, bc = 0;
    for (int i = 0; i < n; i++) {
        x = a[i] & mask ^ at;
        y = a[i] & mask ^ bt;

        if (x & bit) ca[x]++;
        else ac += ca[y];

        if (y & bit) cb[y]++;
        else bc += cb[x];
    }

    if (bc >= ac) ans = at, mav += ac;
    else ans = bt, mav += bc;
}

int main() {
    scanf("%d", &n);

    for (int i = 0; i < n; i++) scanf("%d", &a[i]);
    for (int i = 29; i >= 0; i--) cal(1<<i);
    printf("%d %d\n", mav, ans);
}

// author: rdd6584


#include <bits/stdc++.h>
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
using namespace std;

typedef long long ll;
typedef unsigned long long llu;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<int, pii> piii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef pair<string, int> psi;
typedef pair<char, int> pci;
typedef pair<int, char> pic;
const ll MOD = (ll)1e9 + 7;
const long double PI = 3.141592653589793238462643383279502884197;

ll fac[1] = {1}, inv[1] = {1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll mp(ll a,ll b){ll ret=1;while(b){if(b&1)ret=ret*a%MOD;a=a*a%MOD;b>>=1;}return ret;}
ll cmb(ll r, ll c) {return fac[r] * inv[c] % MOD * inv[r - c] % MOD;}

int k, n, nn;
int a[300000];
int c[300000];
int tree[300001];
int v[300001];
int ans = 0;

void upd(int i) {
    for (; i <= n; i+=i&-i) tree[i]++;
}

int find(int i) {
    int ret = 0;
    for (; i; i -= i&-i) ret += tree[i];
    return ret;
}

ll cal(int bit) {
    int t;
    memset(tree, 0, sizeof(tree));

    for (int i = 0; i < n; i++) {
        c[i] |= a[i] & bit;
        v[i] = c[i];
    }

    sort(v, v + n);
    nn = unique(v, v + n) - v;

    ll mav = 0, cnt = 0;
    for (int i = 0; i < n; i++) {
        t = lower_bound(v, v + nn, c[i]) - v;
        mav += i - find(t + 1);
        upd(t + 1);
    }

    memset(tree, 0, sizeof(tree));
    for (int i = 0; i < n; i++) c[i] ^= bit, v[i] = c[i];
    sort(v, v + n);
    nn = unique(v, v + n) - v;

    for (int i = 0; i < n; i++) {
        t = lower_bound(v, v + nn, c[i]) - v;
        cnt += i - find(t + 1);
        upd(t + 1);
    }

    if (mav <= cnt) {
        for (int i = 0; i < n; i++) c[i] ^= bit;
    }
    else mav = cnt, ans |= bit;

    return mav;
}

int main() {
    scanf("%d", &n);
    k = 1<<29;
    for (int i = 0; i < n; i++) scanf("%d", &a[i]);

    ll mav = 0;
    for (int i = k; i; i>>=1) mav = cal(i);
    printf("%lld %d\n", mav, ans);
}


#include <bits/stdc++.h>
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
using namespace std;

typedef long long ll;
typedef unsigned long long llu;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<int, pii> piii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef pair<string, int> psi;
typedef pair<char, int> pci;
typedef pair<int, char> pic;
const int MOD = 1e9 + 7;
const long double PI = 3.141592653589793238462643383279502884197;

ll fac[1] = {1}, inv[1] = {1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll mp(ll a,ll b){ll ret=1;while(b){if(b&1)ret=ret*a%MOD;a=a*a%MOD;b>>=1;}return ret;}
ll cmb(ll r, ll c) {return (c>r||c<0) ? 0:fac[r] * inv[c] % MOD * inv[r - c] % MOD;}

int n, ans = 0;
ll mav = 0;
int a[300000];
unordered_map<int, int> ca, cb;

void cal(int bit) {
    ca.clear(), cb.clear();
    int mask = bit - 1;
    mask = ~mask;

    int at = ans, bt = ans | bit, x, y;
    ll ac = 0, bc = 0;
    for (int i = 0; i < n; i++) {
        x = a[i] & mask ^ at;
        y = a[i] & mask ^ bt;

        if (x & bit) ca[x]++;
        else ac += ca[y];

        if (y & bit) cb[y]++;
        else bc += cb[x];
    }

    if (bc >= ac) ans = at, mav += ac;
    else ans = bt, mav += bc;
}

int main() {
    scanf("%d", &n);

    for (int i = 0; i < n; i++) scanf("%d", &a[i]);
    for (int i = 29; i >= 0; i--) cal(1<<i);
    printf("%d %lld\n", mav, ans);
}

// author: rdd6584


#include <bits/stdc++.h>
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
using namespace std;

typedef long long ll;
typedef unsigned long long llu;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<int, pii> piii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef pair<string, int> psi;
typedef pair<char, int> pci;
typedef pair<int, char> pic;
const int MOD = 1e9 + 7;
const long double PI = 3.141592653589793238462643383279502884197;

ll fac[1] = {1}, inv[1] = {1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll mp(ll a,ll b){ll ret=1;while(b){if(b&1)ret=ret*a%MOD;a=a*a%MOD;b>>=1;}return ret;}
ll cmb(ll r, ll c) {return (c>r||c<0) ? 0:fac[r] * inv[c] % MOD * inv[r - c] % MOD;}

int n, mav = 0;
ll ans = 0;
int a[300000];
unordered_map<int, int> ca, cb;

void cal(int bit) {
    ca.clear(), cb.clear();
    int mask = bit - 1;
    mask = ~mask;

    int at = ans, bt = ans | bit, x, y;
    ll ac = 0, bc = 0;
    for (int i = 0; i < n; i++) {
        x = a[i] & mask ^ at;
        y = a[i] & mask ^ bt;

        if (x & bit) ca[x]++;
        else ac += ca[y];

        if (y & bit) cb[y]++;
        else bc += cb[x];
    }

    if (bc >= ac) ans = at, mav += ac;
    else ans = bt, mav += bc;
}

int main() {
    scanf("%d", &n);

    for (int i = 0; i < n; i++) scanf("%d", &a[i]);
    for (int i = 29; i >= 0; i--) cal(1<<i);
    printf("%d %d\n", mav, ans);
}

// author: rdd6584


#include <bits/stdc++.h>
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
using namespace std;

typedef long long ll;
typedef unsigned long long llu;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<int, pii> piii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef pair<string, int> psi;
typedef pair<char, int> pci;
typedef pair<int, char> pic;
const int MOD = 1e9 + 7;
const long double PI = 3.141592653589793238462643383279502884197;

ll fac[1] = {1}, inv[1] = {1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll mp(ll a,ll b){ll ret=1;while(b){if(b&1)ret=ret*a%MOD;a=a*a%MOD;b>>=1;}return ret;}
ll cmb(ll r, ll c) {return (c>r||c<0) ? 0:fac[r] * inv[c] % MOD * inv[r - c] % MOD;}

int n, ans = 0;
ll mav = 0;
int a[300000];
unordered_map<int, int> ca, cb;

void cal(int bit) {
    ca.clear(), cb.clear();
    ca.rehash(n); cb.rehash(n);
    int mask = bit - 1;
    mask = ~mask;

    int at = ans, bt = ans | bit, x, y;
    ll ac = 0, bc = 0;
    for (int i = 0; i < n; i++) {
        x = a[i] & mask ^ at;
        y = a[i] & mask ^ bt;

        if (x & bit) ca[x]++;
        else ac += ca[y];

        if (y & bit) cb[y]++;
        else bc += cb[x];
    }

    if (bc >= ac) ans = at, mav += ac;
    else ans = bt, mav += bc;
}

int main() {
    scanf("%d", &n);

    for (int i = 0; i < n; i++) scanf("%d", &a[i]);
    for (int i = 29; i >= 0; i--) cal(1<<i);
    printf("%lld %d\n", mav, ans);
}

// author: rdd6584


#include <bits/stdc++.h>
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
using namespace std;

typedef long long ll;
typedef unsigned long long llu;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<int, pii> piii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef pair<string, int> psi;
typedef pair<char, int> pci;
typedef pair<int, char> pic;
const ll MOD = (ll)1e9 + 7;
const long double PI = 3.141592653589793238462643383279502884197;

ll fac[1] = {1}, inv[1] = {1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll mp(ll a,ll b){ll ret=1;while(b){if(b&1)ret=ret*a%MOD;a=a*a%MOD;b>>=1;}return ret;}
ll cmb(ll r, ll c) {return fac[r] * inv[c] % MOD * inv[r - c] % MOD;}

int k, n;
int a[300000];
int c[300000];
int tree[300001];
int ans = 0;

void upd(int i) {
    for (; i <= n; i+=i&-i) tree[i]++;
}

int find(int i) {
    int ret = 0;
    for (; i; i -= i&-i) ret += tree[i];
    return ret;
}

ll cal(int bit) {
    vector<int> v;
    memset(tree, 0, sizeof(tree));

    for (int i = 0; i < n; i++) {
        c[i] |= a[i] & bit;
        v.push_back(c[i]);
    }

    // 그대로 두는 것.

    sort(all(v));
    v.erase(unique(all(v)), v.end());

    ll mav = 0, cnt = 0;
    for (int i = 0; i < n; i++) {
        int t = lower_bound(all(v), c[i]) - v.begin();
        upd(t + 1);
        cnt += find(n) - find(t + 1);   // 내 위치.
    }

    mav = cnt;

    v.clear();
    memset(tree, 0, sizeof(tree));
    for (int i = 0; i < n; i++) c[i] ^= bit, v.push_back(c[i]);
    sort(all(v));
    v.erase(unique(all(v)), v.end());

    cnt = 0;
    for (int i = 0; i < n; i++) {
        int t = lower_bound(all(v), c[i]) - v.begin();
        upd(t + 1);
        cnt += find(n) - find(t + 1);   // 내 위치.
    }

    // 지금 고른 게 더 안좋은 해.
    // 더 작은 걸 골라야하니까 같은 경우에는...
    // xor한 값이 더 커야만 고른다.

    if (mav <= cnt) {
        for (int i = 0; i < n; i++) c[i] ^= bit;
    }
    else mav = cnt, ans |= bit;

    return mav;
}

int main() {
    scanf("%d", &n);
    k = 1<<30;
    for (int i = 0; i < n; i++) scanf("%d", &a[i]);

    ll mav = 0;
    for (int i = k/2; i >= 1; i/=2) mav = cal(i);
    printf("%lld %d\n", mav, ans);
}


#include <bits/stdc++.h>
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
using namespace std;

typedef long long ll;
typedef unsigned long long llu;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<int, pii> piii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef pair<string, int> psi;
typedef pair<char, int> pci;
typedef pair<int, char> pic;
const ll MOD = (ll)1e9 + 7;
const long double PI = 3.141592653589793238462643383279502884197;

ll fac[1] = {1}, inv[1] = {1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll mp(ll a,ll b){ll ret=1;while(b){if(b&1)ret=ret*a%MOD;a=a*a%MOD;b>>=1;}return ret;}
ll cmb(ll r, ll c) {return fac[r] * inv[c] % MOD * inv[r - c] % MOD;}

int k, n;
int a[300000];
int c[300000];
int tree[300001];
int ans = 0;

void upd(int i) {
    for (; i <= n; i+=i&-i) tree[i]++;
}

int find(int i) {
    int ret = 0;
    for (; i; i -= i&-i) ret += tree[i];
    return ret;
}

ll cal(int bit) {
    vector<int> v;
    v.reserve(n);
    int t;
    memset(tree, 0, sizeof(tree));

    for (int i = 0; i < n; i++) {
        c[i] |= a[i] & bit;
        v.push_back(c[i]);
    }

    sort(all(v));
    v.erase(unique(all(v)), v.end());

    ll mav = 0, cnt = 0;
    for (int i = 0; i < n; i++) {
        t = lower_bound(all(v), c[i]) - v.begin();
        mav += i - find(t + 1);
        upd(t + 1);
    }

    v.clear();
    memset(tree, 0, sizeof(tree));
    for (int i = 0; i < n; i++) c[i] ^= bit, v.push_back(c[i]);
    sort(all(v));
    v.erase(unique(all(v)), v.end());

    cnt = 0;
    for (int i = 0; i < n; i++) {
        t = lower_bound(all(v), c[i]) - v.begin();
        cnt += i - find(t + 1);
        upd(t + 1);
    }

    if (mav <= cnt) {
        for (int i = 0; i < n; i++) c[i] ^= bit;
    }
    else mav = cnt, ans |= bit;

    return mav;
}

int main() {
    scanf("%d", &n);
    k = 1<<29;
    for (int i = 0; i < n; i++) scanf("%d", &a[i]);

    ll mav = 0;
    for (int i = k; i; i>>=1) mav = cal(i);
    printf("%lld %d\n", mav, ans);
}


#include <bits/stdc++.h>
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
using namespace std;

typedef long long ll;
typedef unsigned long long llu;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<int, pii> piii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef pair<string, int> psi;
typedef pair<char, int> pci;
typedef pair<int, char> pic;
const ll MOD = (ll)1e9 + 7;
const long double PI = 3.141592653589793238462643383279502884197;

ll fac[1] = {1}, inv[1] = {1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll mp(ll a,ll b){ll ret=1;while(b){if(b&1)ret=ret*a%MOD;a=a*a%MOD;b>>=1;}return ret;}
ll cmb(ll r, ll c) {return fac[r] * inv[c] % MOD * inv[r - c] % MOD;}

int k, n, nn;
int a[300000];
int tree[300001];
int v[300001];
int ans = 0;

void upd(int i) {
    for (; i <= n; i+=i&-i) tree[i]++;
}

int find(int i) {
    int ret = 0;
    for (; i; i -= i&-i) ret += tree[i];
    return ret;
}

ll cal(int bit) {
    int t;
    memset(tree, 0, sizeof(tree));

    memcpy(v, a, sizeof(v));
    sort(v, v + n);
    nn = unique(v, v + n) - v;

    ll mav = 0, cnt = 0;
    for (int i = 0; i < n; i++) {
        t = lower_bound(v, v + nn, a[i]) - v;
        mav += i - find(t + 1);
        upd(t + 1);
    }

    memset(tree, 0, sizeof(tree));
    for (int i = 0; i < nn; i++) v[i] ^= bit;
    sort(v, v + nn);

    for (int i = 0; i < n; i++) {
        t = lower_bound(v, v + nn, a[i] ^ bit) - v;
        cnt += i - find(t + 1);
        upd(t + 1);
    }

    if (mav > cnt) {
        mav = cnt, ans |= bit;
        for (int i = 0; i < n; i++) a[i] ^= bit;
    }
    return mav;
}

int main() {
    scanf("%d", &n);
    k = 1<<29;
    for (int i = 0; i < n; i++) scanf("%d", &a[i]);

    ll mav = 0;
    for (int i = k; i; i>>=1) mav = cal(i);
    printf("%lld %d\n", mav, ans);
}


#include <bits/stdc++.h>
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
using namespace std;

typedef long long ll;
typedef unsigned long long llu;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<int, pii> piii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef pair<string, int> psi;
typedef pair<char, int> pci;
typedef pair<int, char> pic;
const int MOD = 1e9 + 7;
const long double PI = 3.141592653589793238462643383279502884197;

ll fac[1] = {1}, inv[1] = {1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll mp(ll a,ll b){ll ret=1;while(b){if(b&1)ret=ret*a%MOD;a=a*a%MOD;b>>=1;}return ret;}
ll cmb(ll r, ll c) {return (c>r||c<0) ? 0:fac[r] * inv[c] % MOD * inv[r - c] % MOD;}

int n, ans = 0;
ll mav = 0;
int a[300000];
unordered_map<int, int> ca, cb;

void cal(int bit) {
    ca.clear(), cb.clear();
    int mask = bit - 1;
    mask = ~mask;

    int at = ans, bt = ans | bit, x, y;
    ll ac = 0, bc = 0;
    for (int i = 0; i < n; i++) {
        x = a[i] & mask ^ at;
        y = a[i] & mask ^ bt;

        if (x & bit) ca[x]++;
        else ac += ca[y];

        if (y & bit) cb[y]++;
        else bc += cb[x];
    }

    if (bc >= ac) ans = at, mav += ac;
    else ans = bt, mav += bc;
}

int main() {
    scanf("%d", &n);

    for (int i = 0; i < n; i++) scanf("%d", &a[i]);
    for (int i = 29; i >= 0; i--) cal(1<<i);
    printf("%lld %d\n", mav, ans);
}

// author: rdd6584


#include <bits/stdc++.h>
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
using namespace std;

typedef long long ll;
typedef unsigned long long llu;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<int, pii> piii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef pair<string, int> psi;
typedef pair<char, int> pci;
typedef pair<int, char> pic;
const ll MOD = (ll)1e9 + 7;
const long double PI = 3.141592653589793238462643383279502884197;

ll fac[1] = {1}, inv[1] = {1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll mp(ll a,ll b){ll ret=1;while(b){if(b&1)ret=ret*a%MOD;a=a*a%MOD;b>>=1;}return ret;}
ll cmb(ll r, ll c) {return fac[r] * inv[c] % MOD * inv[r - c] % MOD;}

int k, n;
int a[300000];
int c[300000];
int tree[300001];
int ans = 0;

void upd(int i) {
    for (; i <= n; i+=i&-i) tree[i]++;
}

int find(int i) {
    int ret = 0;
    for (; i; i -= i&-i) ret += tree[i];
    return ret;
}

ll cal(int bit) {
    vector<int> v;
    memset(tree, 0, sizeof(tree));

    for (int i = 0; i < n; i++) {
        c[i] |= a[i] & bit;
        v.emplace_back(c[i]);
    }

    // 그대로 두는 것.

    sort(all(v));
    v.erase(unique(all(v)), v.end());

    ll mav = 0, cnt = 0;
    for (int i = 0; i < n; i++) {
        int t = lower_bound(all(v), c[i]) - v.begin();
        upd(t + 1);
        cnt += find(n) - find(t + 1);   // 내 위치.
    }

    mav = cnt;

    v.clear();
    memset(tree, 0, sizeof(tree));
    for (int i = 0; i < n; i++) c[i] ^= bit, v.emplace_back(c[i]);
    sort(all(v));
    v.erase(unique(all(v)), v.end());

    cnt = 0;
    for (int i = 0; i < n; i++) {
        int t = lower_bound(all(v), c[i]) - v.begin();
        upd(t + 1);
        cnt += find(n) - find(t + 1);   // 내 위치.
    }

    // 지금 고른 게 더 안좋은 해.
    // 더 작은 걸 골라야하니까 같은 경우에는...
    // xor한 값이 더 커야만 고른다.

    if (mav <= cnt) {
        for (int i = 0; i < n; i++) c[i] ^= bit;
    }
    else mav = cnt, ans |= bit;

    return mav;
}

int main() {
    scanf("%d", &n);
    k = 1<<30;
    for (int i = 0; i < n; i++) scanf("%d", &a[i]);

    ll mav = 0;
    for (int i = k/2; i >= 1; i/=2) mav = cal(i);
    printf("%lld %d\n", mav, ans);
}


#include <bits/stdc++.h>
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
using namespace std;

typedef long long ll;
typedef unsigned long long llu;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<int, pii> piii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef pair<string, int> psi;
typedef pair<char, int> pci;
typedef pair<int, char> pic;
const ll MOD = (ll)1e9 + 7;
const long double PI = 3.141592653589793238462643383279502884197;

ll fac[1] = {1}, inv[1] = {1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll mp(ll a,ll b){ll ret=1;while(b){if(b&1)ret=ret*a%MOD;a=a*a%MOD;b>>=1;}return ret;}
ll cmb(ll r, ll c) {return fac[r] * inv[c] % MOD * inv[r - c] % MOD;}

int k, n, nn;
int a[300000];
int tree[300001];
int v[300001];
int ans = 0;

void upd(int i) {
    for (; i <= n; i+=i&-i) tree[i]++;
}

int find(int i) {
    int ret = 0;
    for (; i; i -= i&-i) ret += tree[i];
    return ret;
}

ll cal(int bit) {
    int t;
    memset(tree, 0, sizeof(tree));
    memcpy(v, a, sizeof(v));
    sort(v, v + n);
    nn = unique(v, v + n) - v;
    ll mav = 0, cnt = 0;
    for (int i = 0; i < n; i++) {
        t = lower_bound(v, v + nn, a[i]) - v;
        mav += i - find(t + 1);
        upd(t + 1);
    }

    memset(tree, 0, sizeof(tree));
    for (int i = 0; i < nn; i++) v[i] ^= bit;
    sort(v, v + nn);

    for (int i = 0; i < n; i++) {
        t = lower_bound(v, v + nn, a[i] ^ bit) - v;
        cnt += i - find(t + 1);
        upd(t + 1);
    }

    if (mav > cnt) {
        mav = cnt, ans |= bit;
        for (int i = 0; i < n; i++) a[i] ^= bit;
    }
    return mav;
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    cin >> n;
    k = 1<<29;
    for (int i = 0; i < n; i++) cin >> a[i];

    ll mav = 0;
    for (int i = k; i; i>>=1) mav = cal(i);
    cout << mav << ' ' << ans;
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

typedef long long int ll;
typedef unsigned long long int sll;
typedef long double ld;
#define A 1000000007ll
#define D 1000000000000ll
#define B 998244353ll
#define C 1000000000000000000ll
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define oset tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
#define F first
#define S second
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v) *min_element(v.begin(),v.end())
#define rev(v) reverse(v.begin(),v.end())
#define sor(v) sort(v.begin(),v.end())
#define sorrev(v) sort(v.begin(),v.end(),greater<ll>())
#define uni(v) unique(v.begin(),v.end())
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define ve vector
#define br break
#define PI acos(-1)
#define subt cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n"
auto random_address = [] { char *p = new char; delete p; return sll(p); };
const sll SEED = chrono::steady_clock::now().time_since_epoch().count() * (random_address() | 1);
mt19937_64 rng(SEED);

int main()
{
    FAST;
    ll n;
    cin>>n;
    ve<pair<ll,ll>> a(n);
    ll x=0,y=0;
    for(ll i=0;i<n;i++)
    {
        ll c;
        cin>>c;
        a[i]={c,i};
    }
    sor(a);
    for(ll i=30;i>=0;i--)
    {
        ll co0=0,co1=0,m0=0,m1=0,siz=0,st=0;
        ve<pair<ll,ll>> vx;
        for(ll j=0;j<=n;j++)
        {
            if(j!=n && (j==st || (a[j].F>>(i+1))==(a[j-1].F>>(i+1))))
            {
                siz++;
                vx.pb({a[j].S,(a[j].F>>i)&1});
            }
            else
            {
                sor(vx);
                for(ll k=siz-1;k>=0;k--)
                {
                    if(vx[k].S)
                    {
                        m1++;
                        co0+=m0;
                    }
                    else
                    {
                        m0++;
                        co1+=m1;
                    }
                }
                vx.clear();
                m1=0;
                m0=0;
                siz=0;
                if(j==n)
                    break;
                j--;
                st=j+1;
            }
        }
        if(co1<co0)
        {
            y+=co1;
            x+=(1ll<<i);
        }
        else
            y+=co0;
    }
    cout<<y<<' '<<x;
    subt;
    return 0;
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

typedef long long int ll;
typedef unsigned long long int sll;
typedef long double ld;
#define A 1000000007ll
#define D 1000000000000ll
#define B 998244353ll
#define C 1000000000000000000ll
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define oset tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
#define F first
#define S second
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v) *min_element(v.begin(),v.end())
#define rev(v) reverse(v.begin(),v.end())
#define sor(v) sort(v.begin(),v.end())
#define sorrev(v) sort(v.begin(),v.end(),greater<ll>())
#define uni(v) unique(v.begin(),v.end())
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define ve vector
#define br break
#define PI acos(-1)
#define subt cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n"
auto random_address = [] { char *p = new char; delete p; return sll(p); };
const sll SEED = chrono::steady_clock::now().time_since_epoch().count() * (random_address() | 1);
mt19937_64 rng(SEED);

int main()
{
    FAST;
    ll n;
    cin>>n;
    ve<ll> a(n),b(n,0),val(n+10,0);
    ll x=0,y=0;
    for(ll i=0;i<n;i++)
        cin>>a[i];
    ll in=1;
    for(ll i=30;i>=0;i--)
    {
        ll co0=0,co1=0;
        bool bb=0;
        ve<ll> m0(n+10,0),m1(n+10,0),nval(n+10,0);
        for(ll j=n-1;j>=0;j--)
        {
            if(((a[j]>>i) & 1)==1)
            {
                m1[val[j]]++;
                co0+=m0[val[j]];
                if(nval[val[j]]==0)
                    nval[val[j]]=in++;
                val[j]=nval[val[j]];
            }
            else
            {
                m0[val[j]]++;
                co1+=m1[val[j]];
            }
        }
        if(co1<co0)
        {
            y+=co1;
            x+=(1ll<<i);
        }
        else
            y+=co0;
    }
    cout<<y<<' '<<x;
    subt;
    return 0;
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

typedef long long int ll;
typedef unsigned long long int sll;
typedef long double ld;
#define A 1000000007ll
#define D 1000000000000ll
#define B 998244353ll
#define C 1000000000000000000ll
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define oset tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
#define F first
#define S second
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v) *min_element(v.begin(),v.end())
#define rev(v) reverse(v.begin(),v.end())
#define sor(v) sort(v.begin(),v.end())
#define sorrev(v) sort(v.begin(),v.end(),greater<ll>())
#define uni(v) unique(v.begin(),v.end())
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define ve vector
#define br break
#define PI acos(-1)
#define subt cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n"
auto random_address = [] { char *p = new char; delete p; return sll(p); };
const sll SEED = chrono::steady_clock::now().time_since_epoch().count() * (random_address() | 1);
mt19937_64 rng(SEED);

int main()
{
    FAST;
    ll n;
    cin>>n;
    ve<ll> a(n),b(n,0),val(n,0);
    ll x=0,y=0;
    for(ll i=0;i<n;i++)
        cin>>a[i];
    ll in=1;
    for(ll i=30;i>=0;i--)
    {
        ll co0=0,co1=0,fi=0;
        bool bb=0;
        ve<ll> m0(n+10,0),m1(n+10,0),nval(n+10,0);
        for(ll j=n-1;j>=0;j--)
        {
            if(((a[j]>>i) & 1)==1)
            {
                m1[val[j]]++;
                co0+=m0[val[j]];
                fi++;
            }
            else
            {
                m0[val[j]]++;
                co1+=m1[val[j]];
            }
        }
        if(fi!=0 && fi!=n)
        {
            for(ll j=0;j<n;j++)
                if((a[j]>>i)&1)
                {
                    if(nval[val[j]]==0)
                        nval[val[j]]=in++;
                    val[j]=nval[val[j]];
                }
        }
        if(co1<co0)
        {
            y+=co1;
            x+=(1ll<<i);
        }
        else
            y+=co0;
        if(in>n)
            break;
    }
    cout<<y<<' '<<x;
    subt;
    return 0;
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

typedef long long int ll;
typedef unsigned long long int sll;
typedef long double ld;
#define A 1000000007ll
#define D 1000000000000ll
#define B 998244353ll
#define C 1000000000000000000ll
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define oset tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
#define F first
#define S second
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v) *min_element(v.begin(),v.end())
#define rev(v) reverse(v.begin(),v.end())
#define sor(v) sort(v.begin(),v.end())
#define sorrev(v) sort(v.begin(),v.end(),greater<ll>())
#define uni(v) unique(v.begin(),v.end())
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define ve vector
#define br break
#define PI acos(-1)
#define subt cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n"
auto random_address = [] { char *p = new char; delete p; return sll(p); };
const sll SEED = chrono::steady_clock::now().time_since_epoch().count() * (random_address() | 1);
mt19937_64 rng(SEED);

int main()
{
    FAST;
    ll n;
    cin>>n;
    ve<ll> a(n),b(n,0);
    ll x=0,y=0;
    for(ll i=0;i<n;i++)
        cin>>a[i];
    for(ll i=30;i>=0;i--)
    {
        ll co0=0,co1=0;
        map<ll,ll> m0;
        for(ll j=n-1;j>=0;j--)
        {
            if(((a[j]>>i) & 1)==1)
            {
                co0+=m0[b[j]];
                b[j]+=(1ll<<i);
            }
            else
            {
                m0[b[j]]++;
                co1+=n-j-m0[b[j]];
            }
        }
        if(co1<co0)
        {
            y+=co1;
            x+=(1ll<<i);
        }
        else
            y+=co0;
    }
    cout<<y<<' '<<x;
    subt;
    return 0;
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

typedef long long int ll;
typedef unsigned long long int sll;
typedef long double ld;
#define A 1000000007ll
#define D 1000000000000ll
#define B 998244353ll
#define C 1000000000000000000ll
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define oset tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
#define F first
#define S second
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v) *min_element(v.begin(),v.end())
#define rev(v) reverse(v.begin(),v.end())
#define sor(v) sort(v.begin(),v.end())
#define sorrev(v) sort(v.begin(),v.end(),greater<ll>())
#define uni(v) unique(v.begin(),v.end())
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define ve vector
#define br break
#define PI acos(-1)
#define subt cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n"
auto random_address = [] { char *p = new char; delete p; return sll(p); };
const sll SEED = chrono::steady_clock::now().time_since_epoch().count() * (random_address() | 1);
mt19937_64 rng(SEED);

int main()
{
    FAST;
    ll n;
    cin>>n;
    ve<ll> a(n),b(n,0);
    ll x=0,y=0;
    for(ll i=0;i<n;i++)
        cin>>a[i];
    for(ll i=30;i>=0;i--)
    {
        ll co0=0,co1=0;
        map<ll,ll> m0,m1;
        for(ll j=n-1;j>=0;j--)
        {
            if(((a[j]>>i) & 1)==1)
            {
                m1[b[j]]++;
                co0+=m0[b[j]];
            }
            else
            {
                m0[b[j]]++;
                co1+=m1[b[j]];
            }
        }
        for(ll j=0;j<n;j++)
            b[j]=(a[j]>>i);
        if(co1<co0)
        {
            y+=co1;
            x+=(1ll<<i);
        }
        else
            y+=co0;
    }
    cout<<y<<' '<<x;
    subt;
    return 0;
}


import java.util.* ;
public class Juicer {
        public static void main(String[] args) {
                Scanner sc = new Scanner(System.in) ;
                int n , big = 0 , waste = 0 ;
                n = sc.nextInt() ;
                big = sc.nextInt() ;
                waste = sc.nextInt() ;
                int arr[] = new int [n] ;
                for (int i = 0 ; i < n ; i++) {
                        arr[i] = sc.nextInt() ;
                }
                int ans = 0 ;
                int w = 0 ;
                for (int i = 0 ; i < n ; i++) {
                        if (arr[i] > big) continue ;
                        else {
                                w += arr[i] ;
                        }
                        if (w > waste) {
                                ans++ ;
                                w = 0 ;
                        }
                }
                System.out.println(ans) ;
        }
}


import java.util.*;
import java.io.*;

public class Main {
    //            File file = new File("input.txt");
//            Scanner in = new Scanner(file);
//            PrintWriter out = new PrintWriter(new FileWriter("output.txt"));
    public static void main(String[] args) {
//        Scanner in = new Scanner(System.in);
        FastReader in = new FastReader();

        int n = in.nextInt(), b = in.nextInt(), d = in.nextInt();
        long waste = 0, ans = 0;
        for(int i = 0; i<n; i++) {
            int a = in.nextInt();
            if(a<=b){
                waste+=a;
                if(waste>d){
                    waste = 0;
                    ans++;
                }
            }
        }
        System.out.println(ans);

    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}


import java.util.Scanner;

public class Juicer {

    static Scanner reader=new Scanner (System.in);
    public static void main(String[] args) {
     int n=reader.nextInt();
     int w=reader.nextInt();
     int h=reader.nextInt();
    int o=0;
    int res1=0;
    int res2=0;
     for (int i=0;i<n;i++){
       o  =reader.nextInt();

         if (o<w){
             res1=res1+o;
         }else continue;
     if(res1>h){
         res2=res2+1;
         res1=0;
     }System.out.println(res2);
    }
    }
}


import java.util.Scanner;

public class Juicer {

    static Scanner reader=new Scanner (System.in);
    public static void main(String[] args) {
     int n=reader.nextInt();
     int w=reader.nextInt();
     int h=reader.nextInt();
    int o=0;
    int res1=0;
    int res2=0;
     for (int i=0;i<n;i++){
       o  =reader.nextInt();

         if (o<w){
             res1=res1+o;
         }else continue;
     if(res1>h){
         res2=res2+1;
         res1=0;
     }
    }System.out.println(res2);
    }
}


import java.util.Scanner;

public class Juicer {

    static Scanner reader=new Scanner (System.in);
    public static void main(String[] args) {
     int n=reader.nextInt();
     int w=reader.nextInt();
     int h=reader.nextInt();
    int o=0;
    int res1=0;
    int res2=0;
     for (int i=0;i<n;i++){
       o  =reader.nextInt();
     }for (int j=0; j<n;j++){
         if (o<w){
             res1=res1+o;
         }
     }if(res1>h){
         res2=res2+1;
     }System.out.println(res2);
    }

}


import java.util.Scanner;

public class Juicer {

    static Scanner reader=new Scanner (System.in);
    public static void main(String[] args) {
     int n=reader.nextInt();
     int w=reader.nextInt();
     int h=reader.nextInt();
    int o=0;
    int res1=0;
    int res2=0;
     for (int i=0;i<n;i++){
       o  =reader.nextInt();

         if (o>w){
           continue;
         }else
         {
               res1=res1+o;}
     if(res1>h){
         res2=res2+1;
         res1=0;
     }
    }System.out.println(res2);
    }
}


import java.util.Scanner;

public class Juicer {

    static Scanner reader=new Scanner (System.in);
    public static void main(String[] args) {
     int n=reader.nextInt();
     int w=reader.nextInt();
     int h=reader.nextInt();
    int o=0;
    int res1=0;
    int res2=0;
     for (int i=0;i<n;i++){
       o  =reader.nextInt();

         if (o<w){
             res1=res1+o;
         }else continue;
     }if(res1>h){
         res2=res2+1;
         res1=0;
     }System.out.println(res2);
    }

}


    import java.util.Scanner;

    /**
     *
     * @author abutair
     */
    public class Training {

        public static void main(String[] args) {

            Scanner s = new Scanner(System.in);
            int n = s.nextInt(),b = s.nextInt(),d= s.nextInt();
            int x=0,answer = 0, sum1=0;

            while(n>0)
            {
              x = s.nextInt();
              if(x<=b )
              {
                  sum1 += x;
              }

              if(sum1>d )
              {
                  answer++;
                  sum1=0;
              }
              n--;
            }

            System.out.println(answer);

        }

    }


    import java.util.Scanner;

    /**
     *
     * @author abutair
     */
    public class Training {

        public static void main(String[] args) {

            Scanner s = new Scanner(System.in);
            int n = s.nextInt(),b = s.nextInt(),d= s.nextInt();
            int x=0,answer = 0, sum1=0;

            while(n>0)
            {
              x = s.nextInt();
              if(x<b )
              {
                  sum1 += x;
              }

              if(sum1>d )
              {
                  answer++;
                  sum1=0;
              }
              n--;
            }

            System.out.println(answer);

        }

    }


import java.util.*;
public class Main
{
	public static void main(String[] args) {
	    Scanner sc=new Scanner(System.in);
	    int n=sc.nextInt();
        int b=sc.nextInt();
        int d=sc.nextInt();
        long sum=0;
        long c=0;
        for(int i=0;i<n;i++)
        {
            int x=sc.nextInt();
            if(x<=b)
            sum+=x;

            if(sum>d)
            {
                c++;
                sum=0;
            }

        }

	    System.out.println(c);
	}
}


import java.util.*;
public class Main
{
	public static void main(String[] args) {
	    Scanner sc=new Scanner(System.in);
	    int n=sc.nextInt();
        int b=sc.nextInt();
        int d=sc.nextInt();
        long sum=0;
        for(int i=0;i<n;i++)
        {
            int x=sc.nextInt();
            if(x<=b)
            sum+=x;

        }
        if(sum%d==0)
        sum--;
	    sum/=d;

	    System.out.println(sum);
	}
}


import java.util.*;
public class Main
{
	public static void main(String[] args) {
	    Scanner sc=new Scanner(System.in);
	    int n=sc.nextInt();
        int b=sc.nextInt();
        int d=sc.nextInt();
        long sum=0;
        long c=0;
        for(int i=0;i<n;i++)
        {
            int x=sc.nextInt();
            if(x<=b)
            sum+=x;

            if(sum>d)
            {
                c++;
                sum-=d;
            }

        }

	    System.out.println(c);
	}
}


import java.util.*;
import java.io.*;

public class Main
{
    public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);

        int noOfOranges = sc.nextInt();

        int maxOrangeCapacity = sc.nextInt();

        int squeezeCapacity = sc.nextInt();

        ArrayList <Integer> list = new ArrayList<Integer>();

        int count1 = 0;
        int count2 = 0;
        int count3 = 0;
        int count = 0;

        for(int i=0;i<noOfOranges;i++)
        {
            list.add(sc.nextInt());

            if (list.get(i) <= maxOrangeCapacity )
            {
                count = count + list.get(i);
            }

            if(count > squeezeCapacity )
            {
                count1++;
                count = 0;
            }
        }

        System.out.println(count1);
    }
}


import java.util.*;
import java.io.*;

public class Main
{
    public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);

        int noOfOranges = sc.nextInt();

        int maxOrangeCapacity = sc.nextInt();

        int squeezeCapacity = sc.nextInt();

        ArrayList <Integer> list = new ArrayList<Integer>();

        int count1 = 0;
        int count2 = 0;
        int count3 = 0;

        for(int i=0;i<noOfOranges;i++)
        {
            list.add(sc.nextInt());

            if(list.get(i) > maxOrangeCapacity ){
            count1 = list.get(i) + count1;

            count2 = count2 + count1;}

            else{
                count2 = count2 + count1 + list.get(i);
            }

            if(count2 > squeezeCapacity)
            {
                count3++;
                count1 = 0;
                count2 = 0;
            }
        }

        System.out.println(count3);
    }
}


import java.util.*;

public class ProblemSolving {

    public static void main(String[] args) {

        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int b = scan.nextInt();
        int d = scan.nextInt();
        int[] oranges = new int[n];
        int sum =0;
        int counter = 0;
        for(int i=0;i<n;i++){
            oranges[i] = scan.nextInt();
        }

        for(int i=0;i<n;i++){
            if(oranges[i]<=b){
                sum+=oranges[i];
                if(sum>d){
                    counter++;
                    sum = 0;
                }
            }
        }

        System.out.println(counter);

    }
}


import java.util.Scanner;
public class Main
{
	public static void main(String[] args)
	{
	Scanner sc=new Scanner(System.in);
	int n=sc.nextInt();
	int b=sc.nextInt();
	int d=sc.nextInt();
	int arr[]=new int[n];
	for(int i=0;i<n;i++){
		arr[i]=sc.nextInt();
	}
	int count=0;
	int w=0;
for(int j=0;j<n;j++){
if(arr[j]>b){
	continue;
	}
	else{
	count+=arr[j];
	if(count>d)
		w++;

	}
}

System.out.println(w);
	}
}


import java.util.Scanner;
public class Main
{
	public static void main(String[] args)
	{
	Scanner sc=new Scanner(System.in);
	int n=sc.nextInt();
	int b=sc.nextInt();
	int d=sc.nextInt();
	int arr[]=new int[n];
	for(int i=0;i<n;i++){
		arr[i]=sc.nextInt();
	}
	int count=0;
	int w=0;
for(int j=0;j<n;j++){
if(arr[j]>b){
	continue;
	}
	else{
	count+=arr[j];
	if(count>d){
		w++;
	count=0;
	}
	}

}

System.out.println(w);
	}
}


import java.util.Scanner;

public class Juicer_709A {

	public static void main(String[] args) {
		// TODO Auto-generated method stub

		Scanner input = new Scanner(System.in);

		int n = input.nextInt();
		int b = input.nextInt();
		int d = input.nextInt();
		int x = 0;

		int times = 0;

		for (int i = 0; i < n; i++) {

			if (x <= b) {
				x += input.nextInt();
				}
			if (x > d) {
				times++;
				x = 0 ;
			}

		}
		System.out.println(times);

	}

}


import java.util.Scanner;

public class CodeF {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
	Scanner input = new Scanner(System.in);

	int n = input.nextInt() , j_size = input.nextInt() , w_size = input.nextInt();
	int w_size_2 = w_size;
	int count = 0;
	int arr [] = new int [n];
	for(int i = 0; i < arr.length; i++) {
		arr[i]= input.nextInt();
	}

	for(int i = 0; i < arr.length; i++) {
		if(arr[i] <= j_size) {
			w_size_2 -= arr[i];
			if(w_size_2 < 0) {
				w_size_2 = w_size;
				count++;
			}

		}
	}

	System.out.println(count);

	}

}


import java.util.Scanner;
public class Ps {
    public static void main(String[] args) {
        Scanner input =new Scanner(System.in);
        int n=input.nextInt();
        int b=input.nextInt();
        int d=input.nextInt();
        int count=0;
        int ans=0;
        for (int i = 0; i < n ; i++) {
            int x=input.nextInt();
            if (x<=b) {
                count+=x;
            }
        }
        while (count>d) {
            count-=b;
            ans++;
        }
        System.out.println(ans);
    }
}


import java.util.Scanner;
public class Ps {
    public static void main(String[] args) {
        Scanner input =new Scanner(System.in);
        int n=input.nextInt();
        int b=input.nextInt();
        int d=input.nextInt();
        int count=0;
        int ans=0;
        for (int i = 0; i < n ; i++) {
            int x=input.nextInt();
            if (x<=b) {
                count+=x;
            }
        }
        while (count>d) {
            count-=d;
            ans++;
        }
        System.out.println(ans);
    }
}


import java.util.Scanner;
public class Ps {
    public static void main(String[] args) {
        Scanner input =new Scanner(System.in);
        int n=input.nextInt();
        int b=input.nextInt();
        int d=input.nextInt();
        int count=0;
        int ans=0;
        for (int i = 0; i < n ; i++) {
            int x=input.nextInt();
            if (x<=b) {
                count+=x;
            }
            if (count>d) {
                ans++;
                count=0;
            }
        }

        System.out.println(ans);
    }
}


import java.math.BigInteger;
import java.util.Scanner;

public class ReverseNumber {
    public static void main(final String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int b = sc.nextInt();
        int d = sc.nextInt();
        int waste = 0;
        int count = 0;
        for (int i = 0; i < n; i++) {
            int x = sc.nextInt();
            if (x < b) {
                waste += x;
            }
            if (waste > d) {
                count++;
                waste = 0;
            }
        }
        System.out.println(count);
    }
}