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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) {
    *a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool getmax(T *a, const T &b) {
  if (b > *a) {
    *a = b;
    return true;
  }
  return false;
}
template <class T>
inline void read(T *a) {
  char c;
  while (isspace(c = getchar())) {
  }
  bool flag = 0;
  if (c == '-')
    flag = 1, *a = 0;
  else
    *a = c - 48;
  while (isdigit(c = getchar())) *a = *a * 10 + c - 48;
  if (flag) *a = -*a;
}
const int mo = 1000000007;
template <class T>
T pow(T a, T b, int c = mo) {
  T res = 1;
  for (T i = 1; i <= b; i <<= 1, a = 1LL * a * a % c)
    if (b & i) res = 1LL * res * a % c;
  return res;
}
const int N = 5100;
const int inf = 100000;
int n;
int f[N];
long long a[N];
bool check(long long a, long long b) {
  if (a & 1) return b % a == 0;
  return b % a != 0 && (b % (a / 2) == 0);
}
int main() {
  cin >> n;
  for (int i = (1); i <= (n); ++i) read(a + i);
  a[++n] = 1;
  for (int i = (1); i <= (n - 1); ++i) f[i] = inf;
  int ans = inf;
  for (int i = (n); i >= (1); --i) {
    getmin(&ans, f[i] + i - 1);
    for (int j = (i - 1); j >= (1); --j) {
      long long y = a[i];
      if (j != i - 1 && y % 2 == 0) y /= 2;
      if (check(y, a[j])) getmin(&f[j], f[i] + i - j - 1);
    }
  }
  cout << ans << endl;
  return 0;
}
