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