#include <bits/stdc++.h>
using namespace std;
int n;
int a[100500];
int b[100500];
int main() {
  int num;
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &a[i]);
  }
  num = a[0];
  for (int i = 1; i < n; ++i) {
    int x = a[i];
    while (num != x) {
      if (num > x) {
        num >>= 1;
      } else {
        x >>= 1;
      }
    }
  }
  int res = 0;
  for (int i = 0; i < n; ++i) {
    int x = num;
    b[i] = 0;
    while (x <= a[i]) {
      x <<= 1;
      ++b[i];
    }
    x >>= 1;
    while (x != a[i]) {
      x >>= 1;
      a[i] >>= 1;
      ++res;
      --b[i];
    }
  }
  sort(b, b + n);
  int res2 = 0;
  for (int i = 0; i < n; ++i) {
    res2 += b[i];
  }
  int p = 0;
  for (int i = 0; i < n; ++i) {
    int r3 = res2 + i * (b[i] - p) - (n - i) * (b[i] - p);
    if (r3 < res2) {
      res2 = r3;
      p = b[i];
    }
  }
  cout << res2 + res << endl;
}
