#include <bits/stdc++.h>
using namespace std;
using std::bitset;
const double Pi = acos(-1);
namespace fastIO {
template <class T>
inline void read(T& x) {
  x = 0;
  bool fu = 0;
  char ch = 0;
  while (ch > '9' || ch < '0') {
    ch = getchar();
    if (ch == '-') fu = 1;
  }
  while (ch <= '9' && ch >= '0') x = (x * 10 - 48 + ch), ch = getchar();
  if (fu) x = -x;
}
inline int read() {
  int x = 0;
  bool fu = 0;
  char ch = 0;
  while (ch > '9' || ch < '0') {
    ch = getchar();
    if (ch == '-') fu = 1;
  }
  while (ch <= '9' && ch >= '0') x = (x * 10 - 48 + ch), ch = getchar();
  return fu ? -x : x;
}
template <class T, class... Args>
inline void read(T& t, Args&... args) {
  read(t);
  read(args...);
}
char _n_u_m_[40];
template <class T>
inline void write(T x) {
  if (x == 0) {
    putchar('0');
    return;
  }
  T tmp = x > 0 ? x : -x;
  if (x < 0) putchar('-');
  register int cnt = 0;
  while (tmp > 0) {
    _n_u_m_[cnt++] = tmp % 10 + '0';
    tmp /= 10;
  }
  while (cnt > 0) putchar(_n_u_m_[--cnt]);
}
template <class T>
inline void write(T x, char ch) {
  write(x);
  putchar(ch);
}
}  // namespace fastIO
using namespace fastIO;
int dp[62][114514], cnt[114514], n;
long long a[114514], NOW, add;
inline bool cmp(long long x, long long y) {
  return (x & NOW - 1) > (y & NOW - 1);
}
int main() {
  read(n);
  for (long long int i = 1, iend = n; i <= iend; ++i) read(a[i]);
  memset(dp, 0x3f, sizeof(dp));
  dp[0][0] = 0;
  sort(a + 1, a + n + 1);
  for (long long int i = 1, iend = n; i <= iend; ++i) a[i] = a[n] - a[i];
  for (long long int i = 1, iend = 60; i <= iend; ++i) {
    add = 0;
    sort(a + 1, a + n + 1, cmp);
    cnt[0] = cnt[1] = 0;
    for (long long int j = 1, jend = n; j <= jend; ++j)
      cnt[a[j] >> i - 1 & 1]++;
    dp[i][cnt[1]] = min(dp[i][cnt[1]], cnt[0] + dp[i - 1][0]);
    dp[i][0] = min(dp[i][0], cnt[1] + dp[i - 1][0]);
    for (long long int j = 1, jend = n; j <= jend; ++j) {
      cnt[a[j] >> i - 1 & 1]--;
      cnt[!(a[j] >> i - 1 & 1)]++;
      if (a[j] >> i - 1 & 1) ++add;
      dp[i][add + cnt[1]] = min(dp[i][add + cnt[1]], cnt[0] + dp[i - 1][j]);
      dp[i][add] = min(dp[i][add], cnt[1] + dp[i - 1][j]);
    }
    if (!NOW) NOW = 1;
    NOW <<= 1ll;
  }
  write(dp[60][0]);
  return 0;
}
