#include <bits/stdc++.h>
using namespace std;
struct edge {
  int u, v;
  long long w;
};
long long MOD = 1000000007;
long long _MOD = 1000000009;
double EPS = 1e-10;
int main() {
  int n;
  cin >> n;
  vector<int> x(100001), y(100001);
  vector<int> b(100001, INT_MAX);
  for (int i = 0; i < n; i++) {
    long long a;
    cin >> a;
    for (int r = 0; r < 18; r++)
      for (int l = 0; l < 18; l++) {
        long long _a = (a >> r) << l;
        if (_a <= 100000) b[_a] = min(b[_a], l + r);
      }
    for (int r = 0; r < 18; r++)
      for (int l = 0; l < 18; l++) {
        long long _a = (a >> r) << l;
        if (_a <= 100000 && b[_a] < INT_MAX) {
          x[_a]++;
          y[_a] += b[_a];
          b[_a] = INT_MAX;
        }
      }
  }
  int mini = INT_MAX;
  for (int j = 1; j <= 100000; j++)
    if (x[j] == n) mini = min(mini, y[j]);
  cout << mini << endl;
}
