#include <bits/stdc++.h>
const int MAXN = 5000 + 10;
long long a[MAXN];
int n;
namespace solver1 {
int v[MAXN];
int f[MAXN];
void main() {
  for (int i = 1; i <= n; i++) {
    while (!(a[i] & 1)) {
      a[i] >>= 1;
      v[i]++;
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j < i; j++) {
      if (a[j] % a[i] == 0 && (v[j] + i - j == v[i] || v[i] <= i - j - 1)) {
        f[i] = std::max(f[i], f[j]);
      }
    }
    f[i]++;
  }
  int ans = n;
  for (int i = 1; i <= n; i++) {
    ans = std::min(ans, n - f[i]);
  }
  printf("%d\n", ans);
}
}  // namespace solver1
int main() {
  std::cin >> n;
  for (int i = 1; i <= n; i++) {
    std::cin >> a[i];
  }
  solver1::main();
}
