#include <bits/stdc++.h>
using namespace std;
const long long inf = INT_MAX, df = 5005;
inline long long read() {
  long long x = 0, y = 1;
  char ch = getchar();
  while (ch > '9' || ch < '0') y = (ch == '-') ? -1 : 1, ch = getchar();
  while (ch >= '0' && ch <= '9')
    x = (x << 3) + (x << 1) + ch - '0', ch = getchar();
  return x * y;
}
long long i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, a[df], b[df],
    f[df], c[df];
int main() {
  n = read();
  for (long long i = (1); i <= (n); ++i) a[i] = read();
  for (long long i = (1); i <= (n); ++i) {
    b[i] = 0;
    while (!(a[i] & 1)) a[i] >>= 1, b[i]++;
  }
  f[0] = f[1] = 0;
  for (long long i = (2); i <= (n); ++i) f[i] = i - 1;
  for (long long i = (2); i <= (n); ++i) {
    for (long long j = (i - 1); j >= (1); --j) {
      long long x = i - j;
      if (a[j] % a[i] == 0 && (b[i] - b[j] == x || b[i] <= x - 1)) {
        f[i] = min(f[i], f[j] + x - 1);
      }
    }
  }
  long long ans = inf;
  for (long long i = (1); i <= (n); ++i) ans = min(ans, f[i] + (n - i));
  return printf("%lld\n", ans), 0;
}
