#include <bits/stdc++.h>
using namespace std;
int n;
long long a[5000 + 5];
int dp[5000 + 5];
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%I64d", &a[i]);
  }
  for (int i = n - 1; i >= 0; i--) dp[i] = n - i - 1;
  int ans = n;
  for (int i = n - 1; i >= 0; i--) {
    long long _t = a[i];
    ans = min(ans, dp[i] + i);
    int cc = 0;
    for (int j = i - 1; j >= 0; j--) {
      int flag = 0;
      if (_t % 2 == 0) {
        if (a[j] % _t == _t / 2) flag = 1;
        _t /= 2;
      } else {
        if (a[j] % _t == 0) {
          flag = 1;
        }
      }
      if (flag) {
        dp[j] = min(dp[i] + cc, dp[j]);
      }
      cc++;
    }
  }
  cout << ans << endl;
  return 0;
}
