#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 7, K = 130, INF = 1e9;
int dp[K][N];
long long a[N];
long long geti(long long x, int i) {
  if (i >= 60) return 0;
  return x & (1LL << (i - 1));
}
vector<int> order;
void Sort(int k) {
  vector<int> ll, rr;
  for (int i : order) {
    if (geti(a[i], k))
      ll.push_back(i);
    else
      rr.push_back(i);
  }
  ll.insert(ll.end(), rr.begin(), rr.end());
  order = ll;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  for (int k = 0; k < K; k++)
    for (int i = 0; i < N; i++) dp[k][i] = INF;
  dp[0][0] = 0;
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) order.push_back(i);
  long long mx = 0;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    mx = max(mx, a[i]);
  }
  for (int i = 1; i <= n; i++) a[i] = mx - a[i];
  for (int k = 1; k < K; k++) {
    for (int b = 0; b <= 1; b++) {
      int cnt = 0, carry = 0;
      for (int i = 1; i <= n; i++) {
        bool bi = geti(a[i], k);
        if (bi + b >= 2) carry++;
        if (bi ^ b) cnt++;
      }
      dp[k][carry] = min(dp[k][carry], dp[k - 1][0] + cnt);
      for (int pc = 1; pc <= n; pc++) {
        int id = order[pc - 1];
        bool bi = geti(a[id], k);
        if (bi + b >= 2) carry--;
        if (bi ^ b) cnt--;
        if (bi ^ b ^ 1) cnt++;
        if (b + bi + 1 >= 2) carry++;
        dp[k][carry] = min(dp[k][carry], dp[k - 1][pc] + cnt);
      }
    }
    Sort(k);
  }
  int ans = INF;
  for (int i = 0; i <= n; i++) {
    ans = min(ans, dp[K - 1][i]);
  }
  cout << ans << endl;
}
