Polycarp loves geometric progressions — he collects them. However, as such progressions occur very rarely, he also loves the sequences of numbers where it is enough to delete a single element to get a geometric progression.

In this task we shall define geometric progressions as finite sequences of numbers a1, a2, ..., ak, where ai = c·bi - 1 for some real numbers c and b. For example, the sequences [2, -4, 8], [0, 0, 0, 0], [199] are geometric progressions and [0, 1, 2, 3] is not.

Recently Polycarp has found a sequence and he can't classify it. Help him to do it. Determine whether it is a geometric progression. If it is not, check if it can become a geometric progression if an element is deleted from it.

Input

The first line contains an integer n (1 ≤ n ≤ 105) — the number of elements in the given sequence. The second line contains the given sequence. The numbers are space-separated. All the elements of the given sequence are integers and their absolute value does not exceed 104.

Output

Print 0, if the given sequence is a geometric progression. Otherwise, check if it is possible to make the sequence a geometric progression by deleting a single element. If it is possible, print 1. If it is impossible, print 2.

Examples

Input

4
3 6 12 24


Output

0


Input

4
-8 -16 24 -32


Output

1


Input

4
0 1 2 3


Output

2
import java.io.*;

import java.awt.geom.Point2D;
import java.text.*;
import java.math.*;
import java.util.*;

public class Main implements Runnable {

	final String filename = "";

	int test(int[] a, int n) {
		int state = 0;
		for (int i = 2; i < n; i++) {
			if (state == 0) {
				if (a[i] * a[0] != a[i - 1] * a[1])
					state = 1;
				continue;
			}
			if (state == 1) {
				if (a[i] * a[0] != a[i - 2] * a[1])
					state = 3;
				else
					state = 2;
				continue;
			}
			if (state == 2) {
				if (a[i] * a[0] != a[i - 1] * a[1])
					state = 3;
			}
		}
		if (state == 3)
			return 2;
		if (state == 0)
			return 0;
		return 1;
	}

	public void solve() throws Exception {
		int n = iread();
		int[] a = new int[n];
		int zero = 0, pos = -1;
		for (int i = 0; i < n; i++) {
			a[i] = iread();
			if (a[i] == 0) {
				zero++;
				pos = i;
			}
		}
		if (zero > 1) {
			int ans = 2;
			if (zero == n)
				ans = 0;
			else if (zero == n - 1) {
				if (a[0] != 0)
					ans = 0;
				else
					ans = 1;
			} else if (zero == n - 2)
				if (a[0] != 0)
					ans = 1;
				else
					ans = 2;
			out.write(ans + "\n");
			return;
		}
		if (zero == 1) {
			int ans = 0;
			if (n == 1)
				ans = 0;
			else if (n == 2) {
				if (pos == 1)
					ans = 0;
				else
					ans = 1;
			} else {
				for (int i = pos; i < n - 1; i++)
					a[i] = a[i + 1];
				a[n - 1] = 0;
				ans = test(a, n - 1);
				if (ans < 2)
					ans++;
			}
			out.write(ans + "\n");
			return;
		}
		int a1 = test(a, n);
		for (int i = 0; i < n / 2; i++) {
			int t = a[i];
			a[i] = a[n - i - 1];
			a[n - i - 1] = t;
		}
		int a2 = test(a, n);
		int ans = 1;
		if (a1 == 2 && a2 == 2)
			ans = 2;
		if (a1 == 0 && a2 == 0)
			ans = 0;
		out.write(ans + "\n");
	}

	public void run() {
		try {
			in = new BufferedReader(new InputStreamReader(System.in));
			out = new BufferedWriter(new OutputStreamWriter(System.out));
			// in = new BufferedReader(new FileReader(filename+".in"));
			// out = new BufferedWriter(new FileWriter(filename+".out"));
			solve();
			out.flush();
		} catch (Exception e) {
			e.printStackTrace();
			System.exit(1);
		}
	}

	public int iread() throws Exception {
		return Integer.parseInt(readword());
	}

	public double dread() throws Exception {
		return Double.parseDouble(readword());
	}

	public long lread() throws Exception {
		return Long.parseLong(readword());
	}

	BufferedReader in;

	BufferedWriter out;

	public String readword() throws IOException {
		StringBuilder b = new StringBuilder();
		int c;
		c = in.read();
		while (c >= 0 && c <= ' ')
			c = in.read();
		if (c < 0)
			return "";
		while (c > ' ') {
			b.append((char) c);
			c = in.read();
		}
		return b.toString();
	}

	public static void main(String[] args) {
		try {
			Locale.setDefault(Locale.US);
		} catch (Exception e) {

		}
		new Thread(new Main()).start();
		// new Thread(null, new Main(), "1", 1<<25).start();
	}
}