#include <bits/stdc++.h>
using namespace std;
const int N = 5100;
int n, d[N], p2[N];
long long a[N], f[N];
bool ver(int a, int b) {
  if (a == 0) return 1;
  if (f[a] % f[b] == 0 && (p2[a] + b - a == p2[b] || p2[b] <= b - a - 1))
    return 1;
  return 0;
}
int main() {
  int i;
  cin >> n;
  for (i = 1; i <= n; ++i) {
    cin >> a[i];
    long long t = a[i];
    while (t % 2 == 0) {
      p2[i]++;
      t /= 2;
    }
    f[i] = t;
  }
  d[1] = 1;
  int smax = 0;
  for (i = 2; i <= n; ++i) {
    d[i] = 1;
    for (int j = 0; j < i - 1; ++j)
      if (ver(j + 1, i)) d[i] = max(d[i], d[j + 1] + 1);
    smax = max(smax, d[i]);
  }
  cout << n - smax;
  return 0;
}
