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