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;
const int xd = 987654;
int num[100005];
int mod[100005];
int res[10];
int cou[10];
int znt;
void rez(int N) {
  int t;
  for (int i = 0; i < N / 2; i++) {
    t = num[N - i - 1];
    num[N - i - 1] = num[i];
    num[i] = t;
  }
}
int ab(int x) { return x > 0 ? x : -x; }
int judge0(int N) {
  if (N == 1) return 0;
  znt = 0;
  for (int i = 0; i < N; i++) {
    if (num[i] == 0) znt++;
  }
  if (znt == N)
    return 0;
  else if (znt == N - 1) {
    if (num[0] != 0)
      return 0;
    else
      return 1;
  } else if (N > 3 && znt == N - 2) {
    if (num[0] != 0)
      return 1;
    else
      return 2;
  }
  if (N == 2) {
    if (num[1] % num[0] == 0)
      return 0;
    else
      return 1;
  }
  return -1;
}
int judge(int N) {
  if (N == 3) {
    if (znt == 1) {
      if (num[0] == 0) {
        if (num[2] % num[1] == 0)
          return 1;
        else
          return 2;
      }
      if (num[1] == 0) {
        if (num[2] % num[0] == 0)
          return 1;
        else
          return 2;
      }
      if (num[2] == 0) {
        if (num[1] % num[0] == 0)
          return 1;
        else
          return 2;
      }
    }
    if (num[1] % num[0] == 0 && num[2] % num[1] == 0 &&
        num[1] / num[0] == num[2] / num[1])
      return 0;
    else if (num[1] % num[0] != 0 && num[2] % num[1] != 0 &&
             num[2] % num[0] != 0)
      return 2;
    else
      return 1;
  }
  int non = 0;
  for (int i = 0; i < N - 1; i++) {
    if (num[i] == 0 || num[i + 1] == 0 || num[i + 1] % num[i] != 0) {
      non++;
      mod[i] = xd;
    } else
      mod[i] = num[i + 1] / num[i];
  }
  if (non > 2) return 2;
  memset(cou, 0, sizeof(cou));
  int cnt = 0;
  for (int i = 0; i < N - 1; i++) {
    bool flag = false;
    for (int j = 0; j < cnt; j++) {
      if (mod[i] == res[j]) {
        cou[j]++;
        flag = true;
        break;
      }
    }
    if (!flag) {
      cou[cnt] = 1;
      res[cnt++] = mod[i];
    }
    if (cnt > 3) return 2;
  }
  if (cnt == 1) return 0;
  for (int i = 0; i < cnt; i++) {
    if (res[i] != xd) {
      int s = num[0];
      int cc = 1;
      bool ff = true;
      for (int j = 1; j < N; j++) {
        s *= res[i];
        if (s != num[j]) {
          cc--;
          if (cc < 0) {
            ff = false;
            break;
          }
          s /= res[i];
        }
      }
      if (ff) return 1;
      s = num[1];
      cc = 0;
      ff = true;
      for (int j = 2; j < N; j++) {
        s *= res[i];
        if (s != num[j]) {
          ff = false;
          break;
        }
      }
      if (ff) return 1;
    }
  }
  return 2;
}
int main() {
  int N;
  while (~scanf("%d", &N)) {
    for (int i = 0; i < N; i++) {
      scanf("%d", &num[i]);
    }
    int x0 = judge0(N);
    if (x0 != -1)
      printf("%d\n", x0);
    else {
      int x1 = judge(N);
      rez(N);
      int x2 = judge(N);
      printf("%d\n", (x1 < x2 ? x1 : x2));
    }
  }
  return 0;
}
