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
#include <bits/stdc++.h>
using namespace std;
int len, a[100005], tot, n, cnt[20005], b[100005];
void init() {
  scanf("%d", &len);
  int x;
  for (int i = 1; i <= len; i++) {
    scanf("%d", &a[i]);
    if (!a[i]) tot++;
  }
}
void work() {
  n = len;
  int i, j;
  if (n == 1) {
    puts("0");
    return;
  }
  if (tot == n) {
    puts("0");
    return;
  }
  if (n == 2) {
    if (!a[1])
      puts("1");
    else
      puts("0");
    return;
  }
  if (n == 3) {
    if (!tot) {
      if (a[2] * a[2] == a[1] * a[3])
        puts("0");
      else
        puts("1");
    }
    if (tot == 1) puts("1");
    if (tot == 2) {
      if (a[1])
        puts("0");
      else
        puts("1");
    }
    return;
  }
  if (tot == n - 1) {
    if (a[1])
      puts("0");
    else
      puts("1");
    return;
  }
  if (tot == n - 2) {
    if (a[1])
      puts("1");
    else
      puts("2");
    return;
  }
  if (tot >= 2) {
    puts("2");
    return;
  }
  if (tot == 1) {
    if (n <= 3) {
      puts("1");
      return;
    }
    for (i = 1; i <= n; i++)
      if (a[i])
        b[i] = a[i];
      else
        break;
    for (i++; i <= n; i++) b[i - 1] = a[i];
    for (i = 2; i < n - 1; i++)
      if (b[i] * b[i] != b[i - 1] * b[i + 1]) {
        puts("2");
        return;
      }
    puts("1");
    return;
  }
  for (i = 2; i < n; i++)
    if (a[i] * a[i] != a[i - 1] * a[i + 1]) break;
  if (i == n) {
    puts("0");
    return;
  }
  if (n <= 10) {
    for (i = 1; i <= n; i++) {
      b[0] = 0;
      for (j = 1; j <= n; j++)
        if (j != i) b[++b[0]] = a[j];
      for (j = 2; j < n - 1; j++)
        if (b[j] * b[j] != b[j - 1] * b[j + 1]) break;
      if (j == n - 1) {
        puts("1");
        return;
      }
    }
    puts("2");
    return;
  }
  for (j = 3; j < n; j++)
    if (a[j] * a[j] != a[j - 1] * a[j + 1]) break;
  if (j == n) {
    puts("1");
    return;
  }
  for (j = 2; j < n - 1; j++)
    if (a[j] * a[j] != a[j - 1] * a[j + 1]) break;
  if (j == n - 1) {
    puts("1");
    return;
  }
  for (i = 2; i <= n; i++)
    if (!(a[i] % a[i - 1])) cnt[a[i] / a[i - 1] + 10000]++;
  for (i = 0; i <= 20000; i++)
    if (cnt[i] >= n - 3) {
      b[1] = a[1];
      for (j = 2; j <= n; j++)
        if (a[j] % a[j - 1] || a[j] / a[j - 1] != i - 10000)
          break;
        else
          b[j] = a[j];
      for (j++; j <= n; j++) b[j - 1] = a[j];
      for (j = 2; j < n - 1; j++)
        if (b[j] * b[j] != b[j - 1] * b[j + 1]) break;
      if (j == n - 1) {
        puts("1");
        return;
      }
      puts("2");
      return;
    }
  for (i = 0; i <= 20000; i++) cnt[i] = 0;
  reverse(a + 1, a + n + 1);
  for (i = 2; i <= n; i++)
    if (!(a[i] % a[i - 1])) cnt[a[i] / a[i - 1] + 10000]++;
  for (i = 0; i <= 20000; i++)
    if (cnt[i] >= n - 3) {
      b[1] = a[1];
      for (j = 2; j <= n; j++)
        if (a[j] % a[j - 1] || a[j] / a[j - 1] != i - 10000)
          break;
        else
          b[j] = a[j];
      for (j++; j <= n; j++) b[j - 1] = a[j];
      for (j = 2; j < n - 1; j++)
        if (b[j] * b[j] != b[j - 1] * b[j + 1]) break;
      if (j == n - 1) {
        puts("1");
        return;
      }
      puts("2");
      return;
    }
  puts("2");
  return;
}
int main() {
  init();
  work();
  return 0;
}
