#include <bits/stdc++.h>
using namespace std;
int dp[5010], p[5010];
long long a[5010], b[5010];
bool check(int i, int j) {
  if (a[j] & 1) {
    return (a[i] % a[j] == 0);
  } else {
    if (p[j] == j - i + p[i] && b[i] % b[j] == 0)
      return true;
    else
      return (p[j] <= j - i - 1) && (b[i] % b[j] == 0);
  }
}
int main() {
  int n, i, j;
  scanf("%d", &n);
  for (i = 1; i <= n; i++) {
    scanf("%I64d", &a[i]);
    b[i] = a[i];
    while (b[i] % 2 == 0) {
      b[i] /= 2;
      p[i]++;
    }
  }
  int res = 0;
  for (i = 1; i <= n; i++) {
    dp[i] = 1;
    for (j = 1; j < i; j++) {
      if (check(j, i)) {
        dp[i] = max(dp[j] + 1, dp[i]);
      }
    }
    res = max(res, dp[i]);
  }
  printf("%d\n", n - res);
  return 0;
}
