#include <bits/stdc++.h>
using namespace std;
template <class T>
bool setmax(T &_a, T _b) {
  if (_b > _a) {
    _a = _b;
    return true;
  }
  return false;
}
template <class T>
bool setmin(T &_a, T _b) {
  if (_b < _a) {
    _a = _b;
    return true;
  }
  return false;
}
template <class T>
T gcd(T _a, T _b) {
  return _b == 0 ? _a : gcd(_b, _a % _b);
}
int main() {
  int n;
  scanf("%d", &n);
  static int u[100010], v[100010], t[100010];
  memset(u, 0, sizeof(u));
  memset(v, 0, sizeof(v));
  memset(t, 0, sizeof(t));
  for (int i = int(1); i <= int(n); ++i) {
    int x;
    scanf("%d", &x);
    for (int y = x, c = 0; y > 0; y /= 2, ++c) {
      for (int z = y, d = c; z <= 100000; z *= 2, ++d)
        if (t[z] < i) {
          t[z] = i;
          ++u[z], v[z] += d;
        }
    }
  }
  int ans = 1 << 30;
  for (int i = int(1); i <= int(100000); ++i)
    if (u[i] == n) setmin(ans, v[i]);
  printf("%d\n", ans);
  return 0;
}
