#include <bits/stdc++.h>
using namespace std;
int N, dp[5500];
long long a[5500];
int main() {
  scanf("%d", &N);
  for (int i = 1; i <= N; i++) scanf("%I64d", &a[i]);
  dp[0] = 0;
  for (int i = 1; i <= N; i++) {
    dp[i] = i - 1;
    long long x = a[i];
    for (int j = i - 1; j >= 1; j--) {
      if (x % 2) {
        if (a[j] % x == 0) dp[i] = min(dp[i], dp[j] + i - j - 1);
      } else {
        if (a[j] % (x / 2) == 0 && a[j] / (x / 2) % 2 == 1)
          dp[i] = min(dp[i], dp[j] + i - j - 1);
        x /= 2;
      }
    }
  }
  int ans = N;
  for (int i = 1; i <= N; i++) ans = min(ans, dp[i] + N - i);
  printf("%d\n", ans);
  return 0;
}
