#include <bits/stdc++.h>
const int N = 5005;
long long a[N], cnt[N], dp[N];
bool ok(int j, int i) {
  if (a[j] % a[i]) return false;
  if (cnt[i] == 0)
    return true;
  else {
    if (cnt[i] - cnt[j] == i - j) return true;
    if (cnt[i] < i - j) return true;
    return false;
  }
}
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]++;
    }
  }
  a[n] = 1;
  dp[0] = 0;
  for (int i = 1; i <= n; i++) {
    dp[i] = i;
    for (int j = 0; j < i; j++) {
      if (ok(j, i)) dp[i] = std::min(dp[i], dp[j] + i - j - 1);
    }
  }
  printf("%d\n", dp[n]);
  return 0;
}
