#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
using ll = long long;
using db = long double;
using row = vector<int>;
using ii = pair<int, int>;
const int N = 1e6 + 5, M = 26, A = 6561, LG = 19, MOD = 1e9 + 7;
const int BLOCK = 500;
const long double EPS = 1e-7;
int n, dp[5005], cnt[5005];
ll a[5005];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  for (int i = 1; i < n + 1; i++) {
    cin >> a[i];
    while (a[i] % 2 == 0) a[i] /= 2, cnt[i]++;
  }
  for (int i = 1; i < n + 1; i++) {
    dp[i] = 1;
    for (int j = 1; j < i; j++)
      if (a[j] % a[i] == 0 && (cnt[i] - i == cnt[j] - j || cnt[i] <= i - j - 1))
        dp[i] = max(dp[i], dp[j] + 1);
  }
  cout << n - *max_element(dp + 1, dp + n + 1) << '\n';
  return 0;
}
