#include <bits/stdc++.h>
long long a[5010];
int best[5010];
int two[5010];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%I64d", a + i);
    two[i] = 0;
    while ((a[i] & (1LL << two[i])) == 0) {
      ++two[i];
    }
    best[i] = i;
  }
  int answer = n;
  best[0] = 0;
  for (int i = 0; i < n; ++i) {
    if (best[i] + n - 1 - i < answer) {
      answer = best[i] + n - 1 - i;
    }
    for (int j = i + 1; j < n; ++j) {
      bool check = false;
      if (a[j] % 2 == 1) {
        if (a[i] % a[j] == 0) {
          check = true;
        }
      } else {
        if (j - i > two[j]) {
          if (a[i] % (a[j] >> two[j]) == 0) {
            check = true;
          }
        } else {
          long long t = a[j] >> (j - i);
          if (a[i] % t == 0 && (a[i] / t) % 2 == 1) {
            check = true;
          }
        }
      }
      if (check && best[i] + j - i - 1 < best[j]) {
        best[j] = best[i] + j - i - 1;
      }
    }
  }
  printf("%d\n", answer);
}
