#include <bits/stdc++.h>
using namespace std;
struct Node {
  int legal;
  int opera_num;
} node[500005];
int a[500005];
int maxi;
void init() {
  for (int i = 0; i < 500005; i++) {
    node[i].legal = 0;
    node[i].opera_num = 0;
  }
}
void deal(int x, int num) {
  for (int i = 0; i <= 100; i++) {
    int temp = x;
    for (int j = 0; j <= 100; j++) {
      if (temp > maxi || node[temp].legal == num) break;
      if (node[temp].legal == num - 1) {
        node[temp].legal++;
        node[temp].opera_num += i + j;
      }
      if (temp == 0) break;
      temp *= 2;
    }
    if (temp == 0) break;
    x /= 2;
  }
}
int main() {
  init();
  int n;
  maxi = -1;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
    maxi = max(a[i], maxi);
  }
  for (int i = 0; i < n; i++) {
    deal(a[i], i + 1);
  }
  int answer = 100000000;
  for (int i = 0; i <= maxi; i++)
    if (node[i].legal == n) {
      answer = min(answer, node[i].opera_num);
    }
  printf("%d\n", answer);
  return 0;
}
