#include <bits/stdc++.h>
using namespace std;
const int inf = (int)1e9;
const double INF = 1e12, EPS = 1e-9;
long long a[5000];
int n, dp[5000], two[5000];
int main() {
  cin >> n;
  for (int i = 0; i < (int)n; i++) {
    cin >> a[i];
    two[i] = __builtin_ctzll(a[i]);
  }
  int ans = n;
  for (int i = 0; i < (int)n; i++) {
    dp[i] = i;
    for (int j = 0; j < (int)i; j++) {
      long long c = a[i] >> min(two[i], i - j - 1);
      if (c % 2 == 0 && a[j] % c == c / 2 || c % 2 && a[j] % c == 0)
        dp[i] = min(dp[i], dp[j] + i - j - 1);
    }
    ans = min(ans, dp[i] + n - i - 1);
  }
  cout << ans << endl;
  return 0;
}
