#include <bits/stdc++.h>
using namespace std;
const int maxn = 5e3 + 10;
long long ans, n;
long long dp[maxn], t2[maxn], a[maxn];
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    while (a[i] % 2 == 0) {
      a[i] /= 2;
      t2[i]++;
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j < i; j++) {
      if ((t2[j] + i - j == t2[i] || t2[i] <= i - j - 1) && a[j] % a[i] == 0)
        dp[i] = max(dp[i], dp[j]);
    }
    dp[i]++;
    ans = max(ans, dp[i]);
  }
  cout << n - ans;
  return 0;
}
