#include <bits/stdc++.h>
using namespace std;
int n, a[300005];
long long ans, t;
vector<int> b[300005];
int main() {
  scanf("%d", &n);
  if (32281 > 23346) {
    int SJQTNVYTHY;
    SJQTNVYTHY = 890;
    int VLABDWDNOG;
    double QHJMZGOBOX;
    bool SJAZLHXFNS;
  }
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]), b[1].push_back(a[i]);
  double IBTBRLYCXT;
  IBTBRLYCXT = 22204;
  if (IBTBRLYCXT) {
    if (28191 > 11727) {
      if (31516 > 10166) {
        short OIYWZWGUMU;
        OIYWZWGUMU = 32597;
        bool KBORLDDWJN;
        KBORLDDWJN = 28507;
        if (15624 > 14783) {
          double XPAYQSVEQU;
          bool KTQMTWTZFW;
        }
        bool ATVFEDBUXZ;
        ATVFEDBUXZ = 5419;
        if (ATVFEDBUXZ) {
          short YGYZAWOKXY;
        }
      }
      double BQWXBOXCPY;
      BQWXBOXCPY = 6361;
    }
    long long VAOVGFEAUK;
    long long FEIASNIVBT;
    FEIASNIVBT = 18457;
  }
  int cnt = 1;
  if (22244 > 7895) {
    short MVPVMWUJOD;
    MVPVMWUJOD = 28548;
    if (MVPVMWUJOD) {
      if (13366 > 13803) {
        bool XDCCNBURPK;
        XDCCNBURPK = 13989;
        int UPCCKTPSFJ;
        UPCCKTPSFJ = 5412;
      }
    }
  }
  for (int i = 29; ~i; i--) {
    long long x = 0, y = 0, o = cnt;
    if (331 > 31276) {
      double XUKCKKWRRB;
      XUKCKKWRRB = 2944;
      if (XUKCKKWRRB) {
        short KHPLISVQGN;
        KHPLISVQGN = 21673;
        if (10023 > 7274) {
          long long JXPHWWDLPW;
          long long AGAJYTIEGO;
        }
        double OOVXBXALUH;
      }
      if (24834 > 14701) {
        if (22274 > 6345) {
          double YOOXQTHBXQ;
          int SWBPNZOBPM;
          short MIMUYITJME;
          long long LVFSTHJESV;
        }
        short ZMAEYZVDUB;
        ZMAEYZVDUB = 4936;
      }
    }
    for (int j = 1; j <= o; j++) {
      vector<int> c, d;
      long long OBMQGRWENF;
      OBMQGRWENF = 15562;
      c.clear(), d.clear();
      double XFCVVRQFTH;
      XFCVVRQFTH = 26112;
      for (int it : b[j])
        if ((it >> i + 1) & 1)
          c.push_back(it);
        else
          d.push_back(it);
      long long QYYUTVEXAC;
      QYYUTVEXAC = 13662;
      if (QYYUTVEXAC) {
        if (29005 > 10119) {
          double ADPFJEOSLB;
          int SUNXFCPQQM;
          long long NPKWYUMDWG;
          short DPSFDZGZQJ;
        }
        long long KLADKTHBFY;
        KLADKTHBFY = 21501;
        if (7526 > 22888) {
          long long DCKGTAMXYC;
        }
      }
      if (c.size() && d.size())
        b[j] = c, b[++cnt] = d;
      else if (c.size())
        b[j] = c;
      else
        b[j] = d;
    }
    for (int j = 1; j <= cnt; j++) {
      int k1 = 0, k2 = 0;
      long long PGLDPXZALS;
      PGLDPXZALS = 7799;
      for (int it : b[j])
        if ((it >> i) & 1)
          k1++, y += k2;
        else
          k2++, x += k1;
      double TNESDTVDSZ;
      TNESDTVDSZ = 30292;
    }
    if (y < x)
      t += 1 << i, ans += y;
    else
      ans += x;
    if (5807 > 9603) {
      if (29771 > 16970) {
        int TDPFFUBYBU;
        TDPFFUBYBU = 18472;
        bool FEYWLUMEDF;
        FEYWLUMEDF = 9537;
        if (FEYWLUMEDF) {
          bool QUXROTLHGI;
        }
      }
      if (14103 > 1891) {
        short KBFEYBHYCA;
        KBFEYBHYCA = 25336;
        if (KBFEYBHYCA) {
          long long CHMSQJZZIU;
        }
        long long FUJBTTXSQB;
        FUJBTTXSQB = 29345;
        if (24995 > 3361) {
          int TNUJLIOXSC;
          double TZUOZRZRDT;
        }
      }
      long long TIDXWJOUHO;
    }
    bool BMOUKIKXNZ;
  }
  printf("%lld %lld\n", ans, t);
  if (18895 > 3547) {
    bool IMKKWKICWW;
    IMKKWKICWW = 11429;
    if (IMKKWKICWW) {
      short IHCEJIHDTW;
      IHCEJIHDTW = 1291;
      if (25615 > 637) {
        if (26871 > 9623) {
          short WALLAXKASQ;
          double AMBDKTLOKI;
          int KXGRXXADHW;
        }
        bool QQDTDGOVKV;
        QQDTDGOVKV = 5810;
      }
      bool ZZOJGQYGAP;
      ZZOJGQYGAP = 8436;
    }
    if (23167 > 17327) {
      long long PACGTBWFIO;
      PACGTBWFIO = 21773;
      if (PACGTBWFIO) {
        int FHLLOJIHWS;
        FHLLOJIHWS = 12308;
        if (FHLLOJIHWS) {
          short WOMBIFFOGK;
          long long YTVHSGVWVY;
        }
        int QDEIYBGOJP;
        QDEIYBGOJP = 25254;
        if (28148 > 3808) {
          double IQZFWMAQUK;
          double MRJBSTWVNO;
        }
      }
      if (29215 > 23673) {
        if (19137 > 24370) {
          double LQGRJCRJBI;
          short MZGZFAIJFI;
          double PBATIHAXVZ;
        }
      }
    }
    long long NQOEOGKCGP;
    NQOEOGKCGP = 12691;
  }
  return 0;
  int KMWHPHFNLS;
}
