#include <bits/stdc++.h>
using namespace std;
int n, f[5010], b[5010];
long long a[5010];
bool judge(int l, int r) {
  if (l == 0 || r == n + 1) return true;
  if (a[l] % a[r])
    return false;
  else if (b[l] + r - l != b[r] && r - l - 1 < b[r])
    return false;
  return true;
}
int main() {
  memset(f, 0x3f, sizeof f);
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    while (1) {
      if (a[i] & 1) break;
      b[i]++;
      a[i] >>= 1;
    }
  }
  f[0] = 0;
  for (int i = 1; i <= n + 1; i++)
    for (int j = 0; j < i; j++)
      if (judge(j, i)) f[i] = min(f[i], f[j] + i - j - 1);
  cout << f[n + 1] << endl;
  return 0;
}
