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