#include <bits/stdc++.h>
using namespace std;
int n;
int a[300010], b[300010], dis[300010];
long long ansx;
int read() {
  int x = 0;
  char ch = getchar();
  while (ch < '0' || ch > '9') ch = getchar();
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x;
}
struct discre {
  int num;
  int pos;
} point[300010];
bool cmp(discre a, discre b) { return ((a.num < b.num) ? 1 : 0); }
void discretize() {
  for (int i = 1; i <= n; i++) {
    point[i].num = b[i];
    point[i].pos = i;
  }
  sort(&point[1], &point[n] + 1, cmp);
  int type = 0, pre = -1;
  for (int i = 1; i <= n; i++) {
    if (pre != point[i].num) {
      pre = point[i].num;
      type++;
    }
    dis[point[i].pos] = type;
  }
}
int tree[300010];
int lowbit(int x) { return x & -x; }
void add(int x, int v) {
  while (x <= n) {
    tree[x] += v;
    x += lowbit(x);
  }
  return;
}
long long sum(int x) {
  long long res = 0;
  while (x >= 1) {
    res += tree[x];
    x -= lowbit(x);
  }
  return res;
}
long long check(long long x) {
  for (int i = 1; i <= n; i++) tree[i] = 0;
  long long ans = 0;
  for (int i = 1; i <= n; i++) b[i] = a[i] xor x;
  discretize();
  for (int i = 1; i <= n; i++) {
    add(dis[i], 1);
    ans += sum(n) - sum(dis[i]);
  }
  return ans;
}
int main() {
  n = read();
  for (int i = 1; i <= n; i++) a[i] = read();
  long long orig = check(0);
  for (int i = 0; i <= 29; i++) {
    long long tmp = check(1 << i);
    if (tmp < orig) ansx += (1 << i);
  }
  printf("%lld %lld", check(ansx), ansx);
}
