#include <bits/stdc++.h>
using namespace std;
const int MaxN = 5010;
int n;
long long a[MaxN];
int F[MaxN];
bool u[MaxN][MaxN];
int main() {
  cin >> n;
  for (int i = 1; i <= n; ++i) cin >> a[i];
  for (int i = n; i >= 1; --i) {
    long long k = a[i];
    for (int j = i - 1; j >= 1; --j) {
      if (k % 2 == 0) {
        k /= 2;
        if (a[j] % k == 0 && a[j] / k % 2 == 1) u[j][i] = 1;
      } else if (a[j] % k == 0)
        u[j][i] = 1;
    }
    u[0][i] = 1;
    u[i][n + 1] = 1;
  }
  for (int i = 1; i <= n + 1; ++i) {
    F[i] = MaxN;
    for (int j = 0; j < i; ++j)
      if (u[j][i]) F[i] = min(F[i], F[j] + i - j - 1);
  }
  cout << F[n + 1] << endl;
  return 0;
}
