#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:512000000")
using namespace std;
template <class T>
inline T sqr(T x) {
  return x * x;
}
template <class T>
inline string tostr(const T& x) {
  stringstream ss;
  ss << x;
  return ss.str();
}
const double EPS = 1e-6;
const int INF = 1000 * 1000 * 1000;
const char CINF = 102;
const long long LINF = INF * 1ll * INF;
const long double PI = 3.1415926535897932384626433832795;
int n;
long long src[5100];
long long A[5100];
int P[5100];
int dp[5100];
int main() {
  cin >> n;
  for (int i = 0; i < (n); ++i) {
    cin >> src[i];
    A[i] = src[i];
    P[i] = 0;
    while (A[i] % 2 == 0) {
      A[i] /= 2;
      ++P[i];
    }
  }
  int res = n - 1;
  for (int i = 0; i < (n); ++i) {
    dp[i] = i;
    for (int j = i - 1; j >= 0; --j) {
      int k = i - j - 1;
      if (dp[i] <= k) break;
      if (A[j] % A[i] || (P[j] + k + 1 != P[i] && k < P[i])) continue;
      dp[i] = min(dp[i], dp[j] + k);
    }
    res = min(res, dp[i] + (n - i - 1));
  }
  cout << res;
  return 0;
}
