#include <bits/stdc++.h>
const int N = 5000 + 10;
long long a[N];
int n, d[N];
int two[N];
bool ok(int i, int j) {
  if (a[i] % a[j] != 0) return false;
  if (two[j] == 0) return true;
  if (two[j] - two[i] == j - i) return true;
  if (two[j] - two[i] < j - i && j - two[j] > i) return true;
  if (two[j] - two[i] < j - i && j - two[j] == i && a[i] == a[j] && two[i] == 0)
    return true;
  return false;
}
int main() {
  std::cin >> n;
  for (int i = 0; i < n; ++i) {
    d[i] = i;
    std::cin >> a[i];
    while (a[i] % 2 == 0) {
      ++two[i];
      a[i] /= 2;
    }
  }
  d[n] = n;
  a[n] = 1;
  for (int i = 1; i <= n; ++i)
    for (int j = 0; j < i; ++j)
      if (ok(j, i)) d[i] = std::min(d[i], d[j] + i - j - 1);
  std::cout << d[n] << std::endl;
  return 0;
}
