#include <bits/stdc++.h>
using namespace std;
long long dp[5010];
long long n;
long long a[5010];
long long hs[5010];
int main() {
  memset(dp, -1, sizeof dp);
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    while (a[i] % 2 == 0) {
      a[i] /= 2;
      hs[i]++;
    }
  }
  dp[1] = 0;
  for (int i = 2; i <= n; i++) {
    dp[i] = i - 1;
    for (int j = 1; j < i; j++) {
      if (a[j] % a[i] == 0 && dp[j] != -1 &&
          (hs[j] + i - j == hs[i] || (i - j - 1 >= hs[i]))) {
        dp[i] = min(dp[j] + i - j - 1, dp[i]);
      }
    }
  }
  long long ans = n;
  for (int i = 1; i <= n; i++) {
    if (dp[i] != -1) {
      ans = min(ans, dp[i] + n - i);
    }
  }
  cout << ans << endl;
  return 0;
}
