#include <bits/stdc++.h>
using namespace std;
const int maxn = 5000;
int n, p[maxn], f[maxn];
long long q[maxn];
inline bool check(int x, int y) {
  if (q[x] % q[y]) return false;
  if (p[y] - p[x] == y - x || p[y] <= y - x - 1) return true;
  return false;
}
int main() {
  scanf("%d", &n);
  int ans = n;
  for (int i = 0; i < n; ++i) {
    long long x;
    scanf("%I64d", &x);
    p[i] = __builtin_ctzll(x);
    q[i] = x >> p[i];
  }
  for (int i = 0; i < n; ++i) {
    f[i] = i;
    for (int j = 0; j < i; ++j) {
      if (!check(j, i)) continue;
      f[i] = min(f[i], f[j] + i - j - 1);
    }
    ans = min(ans, f[i] + n - i - 1);
  }
  printf("%d\n", ans);
  return 0;
}
