#include <bits/stdc++.h>
using namespace std;
const int inf = 2147483647;
long long a[5005], f[5005], v[5005];
int n, dp[5005];
void init() {
  int i;
  scanf("%d", &n);
  for (i = 1; i <= n; ++i) {
    scanf("%I64d", &a[i]);
    for (f[i] = a[i]; f[i] % 2 == 0; f[i] /= 2) v[i]++;
  }
}
void work() {
  int i, j, ans = n;
  for (i = 1; i <= n; ++i) {
    dp[i] = 1;
    for (j = 1; j <= i - 1; ++j) {
      if (f[j] % f[i] == 0 && (v[j] + i - j == v[i] || v[i] <= i - j - 1))
        dp[i] = max(dp[j] + 1, dp[i]);
    }
    ans = min(ans, n - dp[i]);
  }
  cout << ans << endl;
}
int main() {
  init();
  work();
}
