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