#include <bits/stdc++.h>
using namespace std;
inline int ___INT() {
  int ret;
  scanf("%d", &ret);
  return ret;
}
int n;
long long A[5005];
int dp[5005];
int cnt2(long long& x) {
  int ret = 0;
  while (!(x & 1)) {
    ++ret;
    x >>= 1;
  }
  return ret;
}
bool can(long long src, long long dest, int steps) {
  int cnt2src = cnt2(src), cnt2dest = cnt2(dest);
  if (src % dest != 0) return false;
  if (cnt2dest - cnt2src == steps) return true;
  if (cnt2dest + 1 <= steps) return true;
  return false;
}
int main() {
  n = ___INT();
  for (int i = 0; i < (n); ++i) {
    cin >> A[i];
  }
  int sub_ans = 1;
  for (int i = n - 1; i >= 0; --i) {
    int steps = 1;
    dp[i] = 1;
    for (int j = i + 1; j < n; ++j) {
      if (can(A[i], A[j], steps)) {
        dp[i] = max(dp[i], dp[j] + 1);
      }
      ++steps;
    }
    sub_ans = max(sub_ans, dp[i]);
  }
  printf("%d\n", n - sub_ans);
  return 0;
}
