#include <bits/stdc++.h>
int dp[5010][2];
long long a[5010];
int main(void) {
  int n;
  scanf("%d", &n);
  dp[0][0] = 0;
  dp[0][1] = 0;
  int tmp;
  long long pa;
  for (int i = 0; i < n; i++) {
    scanf("%I64d", &a[i]);
    if (i > 0) {
      dp[i][0] = dp[i - 1][0] + 1;
    };
    tmp = i;
    pa = a[i];
    for (int j = i - 1; j >= 0; j--) {
      if (pa % 2ll) {
        if (a[j] % pa == 0ll) {
          tmp = std::min(dp[j][1] + i - j - 1, tmp);
        }
      } else {
        if ((a[j] + (pa >> 1ll)) % pa == 0ll) {
          tmp = std::min(dp[j][1] + i - j - 1, tmp);
          pa = (pa >> 1ll);
        } else {
          pa = (pa >> 1ll);
        }
      };
    };
    dp[i][0] = std::min(dp[i][0], tmp);
    dp[i][1] = tmp;
  };
  printf("%d\n", dp[n - 1][0]);
  return 0;
};
