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