#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }
const int MAXN = 100000;
int n;
long long a[MAXN];
long long b[MAXN];
long long dp[MAXN + 1];
long long c[MAXN];
int nc;
long long ndp[MAXN + 1];
void upd(long long &a, long long b) { a = min(a, b); }
long long solve() {
  for (int i = (0); i < (n); ++i) b[i] = a[i];
  dp[0] = 0;
  for (int i = (1); i <= (n); ++i) dp[i] = LLONG_MAX;
  while (true) {
    bool allzero = true;
    for (int i = (0); i < (n); ++i)
      if (b[i] != 0) {
        allzero = false;
        break;
      }
    if (allzero) {
      long long ret = dp[0];
      for (int i = (1); i <= (n); ++i)
        if (dp[i] != LLONG_MAX) ret = min(ret, dp[i] + n - i);
      return ret;
    }
    for (int i = (0); i <= (n); ++i) ndp[i] = LLONG_MAX;
    int x0 = 0, x1 = 0, y0 = 0, y1 = 0;
    for (int i = (0); i < (n); ++i)
      if ((b[i] & 1) == 0)
        ++y0;
      else
        ++y1;
    for (int i = (0); i <= (n); ++i) {
      if (dp[i] != LLONG_MAX) {
        upd(ndp[i + y1], dp[i] + x0 + y1);
        upd(ndp[x1], dp[i] + x1 + y0);
      }
      if (i == n) break;
      if ((b[i] & 1) == 0)
        --y0, ++x0;
      else
        --y1, ++x1;
    }
    nc = 0;
    for (int i = (0); i < (n); ++i)
      if ((b[i] & 1) != 0) c[nc++] = b[i];
    for (int i = (0); i < (n); ++i)
      if ((b[i] & 1) == 0) c[nc++] = b[i];
    for (int i = (0); i < (n); ++i) b[i] = c[i] >> 1;
    for (int i = (0); i <= (n); ++i) dp[i] = ndp[i];
  }
}
void run() {
  scanf("%d", &n);
  for (int i = (0); i < (n); ++i) scanf("%lld", &a[i]);
  printf("%lld\n", solve());
}
int mxn = 10, mxbits = 6;
long long solvestupid() {
  long long mx = a[0];
  for (int i = (1); i < (n); ++i) mx = max(mx, a[i]);
  long long ret = LLONG_MAX;
  for (int delta = (0); delta < (1 << mxbits); ++delta) {
    long long cur = 0;
    for (int i = (0); i < (n); ++i) {
      long long x = mx + delta - a[i];
      while (x != 0) ++cur, x -= x & -x;
    }
    ret = min(ret, cur);
  }
  return ret;
}
void stress() {
  for (int rep = (0); rep < (1000); ++rep) {
    n = rand() % mxn + 1;
    for (int i = (0); i < (n); ++i) a[i] = rand() % (1 << mxbits);
    long long have = solve();
    long long want = solvestupid();
    if (have == want) {
      printf(".");
      continue;
    }
    printf("have=%lld want=%lld\n", have, want);
    printf("%d\n", n);
    for (int i = (0); i < (n); ++i) {
      if (i != 0) printf(" ");
      printf("%lld", a[i]);
    }
    puts("");
    break;
  }
}
int main() {
  run();
  return 0;
}
