#include <bits/stdc++.h>
using namespace std;
const int N = 5e5 + 5;
int n, f[N];
long long a[N], b[N], c[N];
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    scanf("%I64d", a + i);
    a[n + 1] = 1;
    long long t = a[i];
    while (t % 2 == 0) t /= 2, b[i]++;
    c[i] = t;
  }
  for (int i = 1; i <= n + 1; i++) {
    f[i] = i - 1;
    for (int j = 0; j <= i - 1; j++) {
      if (a[j] != 0 && a[i] % a[j] == 0 && i - j <= 50) {
        if (a[i] / a[j] == 1LL << (i - j)) {
          f[i] = min(f[i], f[j] + i - j - 1);
        }
      }
      if (a[i] % 2 == 0) {
        long long l = c[j], r = c[i];
        int cl = b[j], cr = b[i];
        if (l % r != 0) continue;
        if (cr > cl && cr - cl == i - j) {
          f[i] = min(f[j] + i - j - 1, f[i]);
        }
        if (cr - 1 + (cl > 0) <= i - j - 1) {
          f[i] = min(f[j] + i - j - 1, f[i]);
        }
      }
      if (a[i] % 2 == 1)
        if (a[j] % a[i] == 0) {
          f[i] = min(f[j] + i - j - 1, f[i]);
          continue;
        }
    }
  }
  cout << f[n + 1];
}
