#include <bits/stdc++.h>
using namespace std;
const long long N = 5010;
long long ans = 1 << 28, n, seq[N], p2s[N], dp[N];
int main() {
  ios::sync_with_stdio(false);
  cin >> n;
  for (int i = 0; n - i; ++i) {
    cin >> seq[i];
    while (!(seq[i] & 1)) {
      seq[i] /= 2;
      ++p2s[i];
    }
    dp[i] = i;
    for (int j = i - 1; j + 1; --j)
      if (!(seq[j] % seq[i]) &&
          ((p2s[i] <= i - j - 1) || (p2s[i] - p2s[j] == i - j)))
        dp[i] = min(dp[i], dp[j] + i - j - 1);
    ans = min(ans, dp[i] + n - i - 1);
  }
  cout << ans << endl;
  return 0;
}
