#include <bits/stdc++.h>
using namespace std;
int n;
long long a[5010];
int cnt[5010], f[5010];
bool solve(int i, int j) {
  int len = i - j;
  if (a[j] % a[i] != 0) return 0;
  if (cnt[i] < len) return 1;
  return cnt[i] == cnt[j] + len;
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%I64d", a + i);
    cnt[i] = 0;
    while (a[i] % 2 == 0) {
      cnt[i]++;
      a[i] /= 2;
    }
  }
  int ans = 0;
  for (int i = 0; i < n; ++i) {
    f[i] = 0;
    for (int j = 0; j < i; ++j)
      if (solve(i, j)) f[i] = max(f[i], f[j]);
    f[i]++;
    ans = max(ans, f[i]);
  }
  printf("%d\n", n - ans);
}
