#include <bits/stdc++.h>
using namespace std;
int n;
long long a[5010];
int pw2[5010];
int ans = 1e9;
bool check(int x, int y) {
  if (a[x] % a[y] != 0LL) return false;
  if (pw2[y] - (y - x - 1) <= 0) return true;
  return (pw2[x] + 1 == pw2[y] - (y - x - 1));
}
int dp[5010];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%I64d", a + i);
    while (a[i] % 2LL == 0LL) {
      a[i] /= 2LL;
      pw2[i]++;
    }
  }
  for (int i = 1; i <= n; i++) {
    dp[i] = i - 1;
    for (int j = 1; j < i; j++) {
      if (!check(j, i)) continue;
      dp[i] = min(dp[i], dp[j] + (i - j - 1));
    }
    ans = min(ans, dp[i] + n - i);
  }
  printf("%d", ans);
  return 0;
}
