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 main() {
  double n[100001];
  int N, i, zero, sign;
  double div, a, b, c, d, e, f;
  cin >> N;
  zero = 0;
  b = 0;
  c = 0;
  d = 0;
  a = 0;
  f = 0;
  sign = 0;
  for (i = 0; i < N; i++) {
    cin >> n[i];
    if (n[i] == 0) zero++;
  }
  if (N == 1 || N == 2 && n[0] != 0)
    cout << "0" << endl;
  else if (N == zero)
    cout << "0" << endl;
  else if (N - zero == 1) {
    if (n[0] != 0)
      cout << "0" << endl;
    else
      cout << "1" << endl;
  } else if (N - zero == 2 && zero > 1) {
    if (n[0] != 0)
      cout << "1" << endl;
    else
      cout << "2" << endl;
  } else if (N - zero > 1 && zero > 1) {
    cout << "2" << endl;
  } else if (zero == 1) {
    if (n[0] == 0) {
      b = n[2] / n[1];
      for (i = 3; i < N; i++) {
        div = n[i] / n[i - 1];
        if (div != b) {
          cout << "2" << endl;
          return 0;
        }
      }
      cout << "1" << endl;
    } else if (n[1] == 0) {
      b = n[2] / n[0];
      for (i = 3; i < N; i++) {
        div = n[i] / n[i - 1];
        if (div != b) {
          cout << "2" << endl;
          return 0;
        }
      }
      cout << "1" << endl;
    } else {
      b = n[1] / n[0];
      for (i = 2; i < N; i++) {
        if (n[i] == 0) {
          if (i == N - 1) continue;
          if (n[i + 1] / n[i - 1] == b) {
            i++;
            sign++;
            continue;
          }
        }
        div = n[i] / n[i - 1];
        if (div != b) {
          cout << "2" << endl;
          return 0;
        }
      }
      cout << "1" << endl;
    }
  } else if (N == 3) {
    a = n[1] / n[0];
    b = n[2] / n[1];
    if (a == b)
      cout << "0" << endl;
    else
      cout << "1" << endl;
  } else if (N == 4) {
    a = n[1] / n[0];
    b = n[2] / n[1];
    c = n[3] / n[2];
    if (a == b && b == c)
      cout << "0" << endl;
    else if (a == b && b != c || b == c && b != a || n[2] / n[0] == c ||
             a == n[3] / n[1])
      cout << "1" << endl;
    else
      cout << "2" << endl;
  } else {
    a = n[1] / n[0];
    b = n[2] / n[1];
    c = n[3] / n[2];
    d = n[4] / n[3];
    if (a == b && b == c && c == d)
      f = a;
    else {
      if (b == c && c == d)
        f = b;
      else if (a == b && b == c)
        f = a;
      else if (n[2] / n[0] == c && c == d)
        f = c;
      else if (n[3] / n[1] == a && a == d)
        f = a;
      else if (n[4] / n[2] == a && a == b)
        f = a;
      sign++;
    }
    for (i = 5; i < N; i++) {
      if (n[i] / n[i - 1] != f) {
        if (i == N - 1) {
          sign++;
          if (sign > 1) {
            cout << "2" << endl;
            return 0;
          } else
            continue;
        }
        if (n[i + 1] / n[i - 1] == f) {
          i++;
          sign++;
          if (sign > 1) {
            cout << "2" << endl;
            return 0;
          } else
            continue;
        } else {
          cout << "2" << endl;
          return 0;
        }
      }
    }
    if (sign == 1)
      cout << "1" << endl;
    else
      cout << "0" << endl;
  }
  return 0;
}
