#include <bits/stdc++.h>
using namespace std;
const int INF = 987654321;
const long long LINF = 1e15;
const int N_ = 5005;
int N;
long long D[N_], E[N_];
int P2[N_];
int Table[N_];
int res = -1;
int main() {
  int i, j, k;
  scanf("%d", &N);
  for (i = 1; i <= N; i++) {
    scanf("%I64d", &D[i]);
    long long &tmp = E[i];
    tmp = D[i];
    while ((tmp & 1) == 0) tmp >>= 1, ++P2[i];
  }
  for (i = N; i > 0; i--) {
    Table[i] = 1;
    for (j = i + 1; j <= N; j++) {
      bool c1 = (Table[i] <= Table[j]);
      bool c2 = (E[i] % E[j] == 0);
      bool c3 = (P2[j] == P2[i] + (j - i) || P2[j] < (j - i));
      if (c1 && c2 && c3) Table[i] = Table[j] + 1;
    }
  }
  for (i = 1; i <= N; i++) {
    res = max(res, Table[i]);
  }
  printf("%d\n", N - res);
  return 0;
}
