#include <bits/stdc++.h>
using namespace std;
const long long MX = 2e5;
long long cant[MX];
long long cost[MX];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long n;
  cin >> n;
  for (long long i = 0; i < (long long)n; i++) {
    long long num;
    long long x;
    cin >> num;
    x = num;
    long long c = 0;
    while (num > 0) {
      cant[num]++;
      cost[num] += c;
      num /= 2;
      c++;
    }
    cant[0]++;
    cost[0] += c;
  }
  long long ans = cost[0];
  for (long long i = 1; i < MX; i++) {
    long long parc = 0;
    long long sz = 0;
    long long x = i;
    long long quitar = 0;
    long long quitar2 = 0;
    long long step = 0;
    while (x > 0) {
      long long add = cant[x] - quitar2;
      parc += cost[x] - quitar;
      parc += step * add;
      sz += cant[x] - quitar2;
      quitar = cost[x] + sz;
      quitar2 = cant[x];
      if (x % 2 == 1) {
        break;
      }
      x /= 2;
      step++;
    }
    if (sz == n) {
      ans = min(ans, parc);
    }
  }
  cout << ans << endl;
  return 0;
}
