#include <bits/stdc++.h>
using namespace std;
int n, dp[10001], v[10001];
long long f[10001];
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> f[i];
    while (f[i] % 2 == 0) f[i] /= 2, v[i]++;
  }
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    dp[i] = 1;
    for (int j = 1; j < i; j++)
      if (f[j] % f[i] == 0 && (v[i] - i == v[j] - j || v[i] <= i - j - 1))
        dp[i] = max(dp[i], dp[j] + 1);
    ans = max(ans, dp[i]);
  }
  cout << n - ans << '\n';
}
