#include <bits/stdc++.h>
using namespace std;
const int MAX = 5005;
int N, p2[MAX], dp[MAX];
long long A[MAX];
int main() {
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    p2[i] = 0;
    while (A[i] % 2 == 0) {
      p2[i]++;
      A[i] /= 2;
    }
  }
  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)
        if (p2[i] < i - j or p2[i] - p2[j] == i - j)
          dp[i] = min(dp[i], dp[j] + (i - j - 1));
    }
  }
  int res = MAX;
  for (int i = 0; i < N; i++) {
    res = min(res, dp[i] + N - 1 - i);
  }
  cout << res << endl;
}
