#include <bits/stdc++.h>
using namespace std;
long long s[5010];
int dp[5010];
long long even[5010];
long long odd[5010];
bool ok(int i, int j) {
  if (odd[i] % odd[j] != 0) return false;
  if (even[i] + j - i == even[j]) return true;
  if (even[j] <= j - i - 1) return true;
  return false;
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%I64d", &s[i]);
    long long now = s[i];
    even[i] = 0;
    while (now % 2 == 0) {
      even[i]++;
      now /= 2;
    }
    odd[i] = now;
  }
  for (int i = 0; i < n; i++) {
    dp[i] = 1;
    for (int j = 0; j < i; j++)
      if (ok(j, i)) dp[i] = max(dp[i], dp[j] + 1);
  }
  int mm = 0;
  for (int i = 0; i < n; i++) mm = max(mm, dp[i]);
  printf("%d\n", n - mm);
  return 0;
}
