#include <bits/stdc++.h>
using namespace std;
const int maxn = 5100;
long long a[maxn];
long long b[maxn];
long long n;
long long dp[maxn];
long long tav2(long long i) {
  if (i % 2) return 0;
  return tav2(i / 2) + 1;
}
long long ans;
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n;
  for (long long y = 0; y < n; y++)
    cin >> a[y], b[y] = tav2(a[y]), a[y] /= (1LL * (1 << b[y]));
  a[n] = 1;
  for (long long y = n - 1; y > -1; y--) {
    for (long long x = y + 1; x <= n; x++) {
      if (a[y] % a[x] == 0 && (x - y == b[x] - b[y] || b[x] < x - y))
        dp[y] = max(dp[y], dp[x] + 1);
    }
    ans = max(ans, dp[y]);
  }
  cout << n - ans;
}
