#include <bits/stdc++.h>
using namespace std;
const int N = 5005;
long long a[N];
int c[N], f[N];
bool check(int i, int j) {
  if (a[i] % a[j] != 0) return false;
  if (j - 1 - i >= c[j]) return true;
  if (c[i] + j - i != c[j]) return false;
  return true;
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%lld", a + i);
    while (!(a[i] & 1)) {
      a[i] >>= 1;
      c[i]++;
    }
  }
  int ans = n;
  for (int i = 1; i <= n; i++) {
    f[i] = i - 1;
    for (int j = i - 1; j > 0; j--) {
      if (!check(j, i)) continue;
      f[i] = min(f[i], f[j] + i - 1 - j);
    }
    ans = min(ans, f[i] + n - i);
  }
  printf("%d", ans);
}
