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