5
1 8 1 7 9
 4
6 7 4 5
 5
36 37 6 18 36
 3
5 1 3
 200
2 1 1 1 2 1 2 1 1 1 2 1 2 2 2 1 1 2 1 2 1 1 1 2 2 1 2 1 1 2 1 1 1 2 1 1 2 2 2 2 2 2 2 2 2 2 1 2 2 1 2 1 2 2 1 1 2 2 2 2 2 2 2 1 1 1 2 1 2 2 1 1 2 1 2 2 2 1 2 1 1 1 2 1 1 2 2 1 2 2 1 2 2 1 1 2 1 1 1 1 1 2 2 1 1 2 1 2 2 2 1 2 1 1 1 2 2 1 2 2 2 1 1 2 1 2 2 1 2 2 2 1 1 2 2 1 2 1 1 2 2 1 2 1 2 1 2 2 2 1 1 2 2 1 1 2 1 1 1 2 2 2 1 2 2 2 1 2 1 1 1 1 2 1 2 1 2 1 1 1 2 2 2 1 2 1 1 2 2 1 1 1 1 1 2 2 2 1 2 2
 10
104105246720 52052623360 213207545282560 426415090565120 6354080 832841973760 26650943160320 6506577920 50832640 832841973760
 3
9 4 4
 10
3 3 3 3 3 3 3 3 3 3
 100
24 33 88 55 4 24 19 19 63 90 9 47 24 74 21 43 20 100 58 15 36 66 13 4 9 51 24 96 50 27 100 41 92 9 67 94 17 11 98 24 72 57 96 85 50 9 45 41 63 76 80 59 25 67 21 84 88 15 62 60 79 65 5 66 1 85 92 100 61 75 44 96 53 97 2 28 83 42 60 42 34 73 44 99 58 46 75 100 75 55 35 52 93 80 69 75 50 67 100 77
 200
1 2 1 2 2 1 2 2 2 1 1 1 2 2 1 2 2 1 2 1 1 2 1 2 1 2 2 1 2 2 1 2 1 2 1 2 1 2 2 1 1 1 1 2 1 1 2 2 1 2 1 1 2 2 2 1 2 1 1 1 1 1 1 1 2 1 2 2 2 2 2 2 1 1 1 2 2 2 2 2 1 2 1 2 1 2 2 2 1 1 1 1 2 1 1 1 2 2 1 2 1 1 1 2 2 1 1 2 1 2 1 2 1 1 1 2 2 2 1 1 1 2 2 2 1 2 1 2 2 1 2 2 2 1 1 1 1 1 2 2 2 2 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<< "[ ";
  for (auto v : V) os << v << " ";
  return os << "]";
}
template <class T>
ostream& operator<<(ostream& os, set<T> S) {
  os << "{ ";
  for (auto s : S) os << s << " ";
  return os << "}";
}
template <class L, class R>
ostream& operator<<(ostream& os, pair<L, R> P) {
  return os << "(" << P.first << "," << P.second << ")";
}
template <class L, class R>
ostream& operator<<(ostream& os, map<L, R> M) {
  os << "{ ";
  for (auto m : M) os << "(" << m.F << ":" << m.S << ")";
  return os << "}";
}
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cout << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  cout.write(names, comma - names) << " : " << arg1 << " | ";
  __f(comma + 1, args...);
}
const int N = 5e3 + 100;
int dp[N];
long long A[N];
int ep[N];
int n;
void pre() {
  for (int i = 1; i <= n; ++i) {
    while (A[i] % 2 == 0) {
      A[i] /= 2;
      ++ep[i];
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cout << fixed << setprecision(25);
  cin >> n;
  for (int i = 1; i <= n; ++i) cin >> A[i];
  reverse(A + 1, A + n + 1);
  pre();
  int mx = 0;
  dp[1] = 1;
  for (int i = 2; i <= n; ++i) {
    dp[i] = 1;
    for (int j = 1; j < i; ++j) {
      if (A[i] % A[j] == 0 && (ep[j] < i - j || ep[j] - ep[i] == i - j)) {
        dp[i] = max(dp[i], dp[j] + 1);
      }
    }
    mx = max(mx, dp[i]);
  }
  cout << n - mx << "\n";
  return 0;
}
