#include <bits/stdc++.h>
using namespace std;
int n, c;
vector<int> v[100100];
int main() {
  cin >> n;
  for (int i = 0; i < (int)n; i++) {
    cin >> c;
    while (c > 0) {
      v[i].push_back(c % 2);
      c /= 2;
    }
  }
  while (1) {
    if (v[0].size() == 0) break;
    c = v[0][v[0].size() - 1];
    bool ok = 1;
    for (int i = 0; i < (int)n; i++)
      if (v[i].size() == 0 || v[i][v[i].size() - 1] != c) ok = 0;
    if (ok) {
      for (int i = 0; i < (int)n; i++) v[i].pop_back();
    } else
      break;
  }
  int ans = 0;
  for (int i = 0; i < (int)n; i++) {
    int kz = 0;
    for (int j = 0; j < (int)v[i].size(); j++)
      if (v[i][j] == 1) kz++;
    while (kz > 0) {
      if (v[i][0] == 1) kz--;
      v[i].erase(v[i].begin());
      ans++;
    }
  }
  int ans2 = 999999999;
  for (int j = 0; j < (int)100; j++) {
    int tans = 0;
    for (int i = 0; i < (int)n; i++) tans += abs(j - (int)v[i].size());
    ans2 = min(ans2, tans);
  }
  cout << ans + ans2;
  return 0;
}
