#include <bits/stdc++.h>
using namespace std;
const int MAXN = 5010;
long long b[MAXN + 10], e[MAXN + 10];
int git(int i, int j) {
  if (b[i] % b[j] != 0) {
    return 0;
  }
  if (e[j] == e[i] + (j - i)) {
    return 1;
  }
  if (e[j] < j - i) {
    return 1;
  }
  return 0;
}
int dp[MAXN + 10];
int main(void) {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < (n); ++i) {
    scanf("%lld", &b[i]);
    while (b[i] % 2 == 0) {
      ++e[i];
      b[i] /= 2;
    }
  }
  int res = 0;
  for (int i = 0; i < (n); ++i) {
    dp[i] = 1;
    for (int j = 0; j < (i); ++j) {
      if (git(j, i)) {
        dp[i] = max(dp[i], dp[j] + 1);
      }
    }
    res = max(res, dp[i]);
  }
  printf("%d\n", n - res);
  return 0;
}
