#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100005;
int a[MAXN];
int n;
int Bit[MAXN][40];
void input() {
  memset(Bit, -1, sizeof(Bit));
  for (int i = 1; i <= n; i++) {
    scanf("%d", a + i);
  }
}
void solve() {
  int j, k;
  for (int i = 1; i <= n; i++) {
    k = 1;
    while (a[i]) {
      Bit[i][k] = a[i] % 2;
      a[i] = a[i] / 2;
      k++;
    }
    for (j = 32;; j--) {
      if ((k - (32 - j) - 1) < 1) break;
      Bit[i][j] = Bit[i][k - (32 - j) - 1];
    }
    for (; j > 0; j--) {
      Bit[i][j] = -1;
    }
  }
  int flag = 0;
  int ans[40];
  memset(ans, 0, sizeof(ans));
  int cost = 0;
  int precost = 0;
  for (int i = 32; i >= 1; i--) {
    precost = cost;
    flag = 0;
    int num = 0;
    for (j = 1; j <= n; j++) {
      if (Bit[j][i] == 0 || Bit[j][i] == -1) {
        flag = 1;
        break;
      }
    }
    if (flag) {
      for (j = 1; j <= n; j++) {
        if (Bit[j][i] == -1) {
          num++;
          cost++;
          Bit[j][i] = 0;
        } else if (Bit[j][i] == 1) {
          num += 2;
          cost += 2;
          Bit[j][i] = 0;
          for (k = i - 1; k >= 1; k--) {
            if (Bit[j][k] != -1) {
              num++;
              cost++;
              Bit[j][k] = -1;
            } else {
              break;
            }
          }
        } else if (Bit[j][i] == 0) {
          for (k = i - 1; k >= 1; k--) {
            if (Bit[j][k] != -1) {
              num++;
            } else {
              break;
            }
          }
        }
      }
    } else {
      for (j = 1; j <= n; j++) {
        for (k = i - 1; k >= 1; k--) {
          if (Bit[j][k] != -1) {
            num++;
          } else {
            break;
          }
        }
      }
    }
    ans[i] = num + precost;
  }
  int minnum = ans[1];
  for (int i = 2; i <= 32; i++) {
    minnum = min(minnum, ans[i]);
  }
  printf("%d\n", minnum);
}
int main(void) {
  while (~scanf("%d", &n)) {
    input();
    solve();
  }
  return 0;
}
