#include <bits/stdc++.h>
using namespace std;
int dp[5005][5005], precal[5005];
long long ara[5005];
int solve(int now, int prv) {
  if (now < 0) return 0;
  int &ret = dp[now][prv];
  if (ret != -1) return ret;
  long long prvval = (ara[prv] >> min(prv - now - 1, precal[prv]));
  ret = 1 + solve(now - 1, prv);
  if ((prvval % 2 && ara[now] % prvval == 0) ||
      (prvval % 2 == 0 && ara[now] % prvval == (prvval >> 1)))
    ret = min(ret, solve(now - 1, now));
  return ret;
}
int main() {
  int i, n;
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%I64d", &ara[i]);
    precal[i] = __builtin_ctzll(ara[i]);
  }
  memset(dp, -1, sizeof(dp));
  int ans = solve(n - 2, n - 1);
  precal[n - 1] = 0;
  ara[n - 1] = 1;
  memset(dp, -1, sizeof(dp));
  ans = min(ans, 1 + solve(n - 2, n - 1));
  cout << ans << endl;
  return 0;
}
