#include <bits/stdc++.h>
using namespace std;
int arr[100005];
int cost[100005];
int reached_from[100005];
void markup(int n, int c) {
  while (n < 100005) {
    if (cost[n] == -1) {
      cost[n] = c;
    } else {
      cost[n] += c;
    }
    reached_from[n]++;
    c += 1;
    n *= 2;
  }
}
void mark(int n) {
  int is_odd = n % 2;
  markup(n, 0);
  n /= 2;
  int c = 1;
  while (n > 0) {
    if (is_odd) {
      markup(n, c);
    } else {
      reached_from[n]++;
      if (cost[n] == -1) {
        cost[n] = c;
      } else {
        cost[n] += c;
      }
    }
    is_odd = n % 2;
    c += 1;
    n /= 2;
  }
}
int main() {
  int n;
  scanf("%d", &n);
  memset(cost, -1, sizeof(cost));
  memset(reached_from, 0, sizeof(reached_from));
  for (int i = 0; i < n; i++) {
    scanf("%d", arr + i);
    mark(arr[i]);
  }
  int mincost = -1;
  int result = -1;
  for (int i = 0; i < 100005; i++) {
    if (reached_from[i] == n && (mincost == -1 || cost[i] < mincost)) {
      mincost = cost[i];
      result = i;
    }
  }
  printf("%d\n", cost[result]);
}
