#include <bits/stdc++.h>
using namespace std;
long long a[100100];
int id[100100], tmp[100100], pos[100100];
int dp[62][100100];
inline void smin(int &a, int b) {
  if (a > b) a = b;
}
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) scanf("%I64d", a + i);
  sort(a + 1, a + n + 1);
  for (int i = 1; i <= n; i++) a[i] = a[n] - a[i];
  memset(dp, 0x3f, sizeof(dp));
  dp[0][0] = 0;
  for (int i = 1; i <= n; i++) id[i] = i;
  for (int i = 0; i < 60; i++) {
    int nn = 0;
    for (int j = 1; j <= n; j++) {
      if ((a[id[j]] >> i) & 1) tmp[++nn] = id[j], pos[j] = nn;
    }
    int mid = nn;
    for (int j = 1; j <= n; j++) {
      if (~(a[id[j]] >> i) & 1) tmp[++nn] = id[j], pos[j] = nn;
    }
    smin(dp[i + 1][0], dp[i][0] + mid);
    smin(dp[i + 1][mid], dp[i][0] + n - mid);
    int A = 0, B = 0;
    for (int j = 1; j <= n; j++) {
      if (pos[j] <= mid)
        A++;
      else
        B++;
      smin(dp[i + 1][A], dp[i][j] + mid - A + B);
      smin(dp[i + 1][mid + B], dp[i][j] + A + n - mid - B);
    }
    for (int j = 1; j <= n; j++) id[j] = tmp[j];
  }
  cout << dp[60][0] << endl;
  return 0;
  int ans = 0x3f3f3f3f;
  for (int i = 0; i <= n; i++) ans = min(ans, dp[61][i] + i);
  cout << ans << endl;
  return 0;
}
