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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.PrintWriter;
import java.util.StringTokenizer;
import java.math.BigInteger;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 * @author AlexFetisov
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskD_MathSeq solver = new TaskD_MathSeq();
		solver.solve(1, in, out);
		out.close();
	}
}

class TaskD_MathSeq {
    public void solve(int testNumber, InputReader in, PrintWriter out) {
        int n = in.nextInt();
        long[] a = new long[n];
        int[] p = new int[n];
        for (int i = 0; i < n; ++i) {
            a[i] = in.nextLong();
            while (a[i] % 2 == 0) {
                ++p[i];
                a[i] /= 2;
            }
        }
        int res = n - 1;
        int[] dp = new int[n];
        for (int i = 0; i < n; ++i) {
            dp[i] = i;
            for (int j = i - 1; j >= 0; --j) {
                int k = i - j - 1;
                if (dp[i] <= k) {
                    break;
                }
                if (a[j] % a[i] != 0 || (p[j] + k + 1 != p[i] && k < p[i])) {
                    continue;
                }
                dp[i] = Math.min(dp[i], dp[j] + k);
            }
            res = Math.min(res, dp[i] + (n - i - 1));
        }
        out.println(res);
    }
}

class InputReader {
    private BufferedReader reader;
    private StringTokenizer stt;

    public InputReader(InputStream stream) {
        reader = new BufferedReader(new InputStreamReader(stream));
    }

    public String nextLine() {
        try {
            return reader.readLine();
        } catch (IOException e) {
            return null;
        }
    }

    public String nextString() {
        while (stt == null || !stt.hasMoreTokens()) {
            stt = new StringTokenizer(nextLine());
        }
        return stt.nextToken();
    }

    public int nextInt() {
        return Integer.parseInt(nextString());
    }

    public long nextLong() {
        return Long.parseLong(nextString());
    }

}

