#include <bits/stdc++.h>
using namespace std;
const int M = 5000 + 10;
long long int a[M];
int dp[M];
long long int maxodd[M];
long long int fac2[M];
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    long long int tmp = a[i];
    while (tmp % 2 == 0) {
      fac2[i]++;
      tmp = tmp / 2;
    }
    maxodd[i] = tmp;
  }
  dp[1] = 1;
  for (int i = 2; i <= n; i++) {
    dp[i] = 1;
    for (int j = 1; j <= i - 1; j++) {
      if (maxodd[j] % maxodd[i] == 0) {
        bool ok1 = (fac2[i] - fac2[j] == i - j);
        bool ok2 = (fac2[i] <= i - j - 1);
        if (ok1 || ok2) {
          dp[i] = max(dp[i], dp[j] + 1);
        }
      }
    }
  }
  int res = dp[1];
  for (int i = 1; i <= n; i++) {
    res = max(res, dp[i]);
  }
  cout << n - res << endl;
  return 0;
}
