#include <bits/stdc++.h>
using namespace std;
void solve() {
  int i, j, k, l, r, x, y;
  string s;
  int N, dp[5010];
  signed long long A[5010];
  cin >> N;
  int ret = N;
  for (x = 0; x < N; x++) {
    cin >> A[x];
    dp[x] = x;
    signed long long X = A[x];
    for (y = x - 1; y >= 0; y--) {
      if (X % 2 == 0 && (A[y] % X) == X / 2)
        dp[x] = min(dp[x], dp[y] + x - y - 1);
      if (X % 2 == 1 && (A[y] % X) == 0) dp[x] = min(dp[x], dp[y] + x - y - 1);
      if (X % 2 == 0) X >>= 1;
    }
    ret = min(ret, dp[x] + (N - (x + 1)));
  }
  cout << ret << endl;
}
int main(int argc, char** argv) {
  string s;
  int i;
  if (argc == 1) ios::sync_with_stdio(false);
  for (i = 0; i < argc - 1; i++) s += argv[i + 1], s += '\n';
  for (i = 0; i < s.size(); i++) ungetc(s[s.size() - 1 - i], stdin);
  solve();
  return 0;
}
