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