#include <bits/stdc++.h>
using namespace std;
const int N = 5001;
long long a[N];
int dp[N], cnt[N];
bool ok(int i, int j) {
  if (a[i] % a[j]) return false;
  if (cnt[i] < cnt[j]) {
    if (cnt[j] - cnt[i] > j - i) return false;
    if (cnt[j] - cnt[i] == j - i) return true;
    if (cnt[j] > j - i - 1) return false;
    return true;
  }
  if (cnt[j] > j - i - 1) return false;
  return true;
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%I64d", a + i);
    while (a[i] % 2 == 0) a[i] /= 2, cnt[i]++;
  }
  fill(dp, dp + n, 1);
  for (int i = n - 1; i > -1; i--)
    for (int j = i + 1; j < n; j++)
      if (ok(i, j)) dp[i] = max(dp[i], dp[j] + 1);
  int ans = n - 1;
  for (int i = 0; i < n; i++) ans = min(ans, n - dp[i]);
  printf("%d\n", ans);
}
