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;
struct iii {
  int a, b, c;
  iii() {}
  iii(int a, int b, int c) : a(a), b(b), c(c) {}
  bool operator<(const iii &e) const {
    return a < e.a || a == e.a && (b < e.b || b == e.b && c < e.c);
  }
};
template <typename T>
T sq(const T &x) {
  return x * x;
}
template <typename T>
void minl(T &a, const T &b) {
  if (a > b) a = b;
}
template <typename T>
void maxl(T &a, const T &b) {
  if (a < b) a = b;
}
template <typename T>
void usort(vector<T> &a) {
  sort((a).begin(), (a).end());
  a.erase(unique((a).begin(), (a).end()), a.end());
}
template <typename T>
int index(const vector<T> &a, const T &x) {
  return lower_bound((a).begin(), (a).end(), x) - a.begin();
}
pair<int, int> operator+(const pair<int, int> &a, const pair<int, int> &b) {
  return pair<int, int>(a.first + b.first, a.second + b.second);
}
pair<int, int> operator-(const pair<int, int> &a, const pair<int, int> &b) {
  return pair<int, int>(a.first - b.first, a.second - b.second);
}
long long cross(const pair<int, int> &a, const pair<int, int> &b) {
  return (long long)a.first * b.second - (long long)b.first * a.second;
}
double bs(int a, int b) { return (double)b / a; }
inline bool z(double x) { return fabs(x) < 1e-8; }
int n;
int a[100000];
struct Frac {
  int a, b;
  Frac() {}
  Frac(int _a, int _b) {
    a = _a;
    b = _b;
  }
  bool operator==(const Frac &e) const {
    if (e.b == 0) return false;
    if (b == 0) return false;
    return a * e.b == b * e.a;
  }
};
bool check(int a1, int a2) {
  if (a2 == 0) {
    for (int i = 3; i < n; i++) {
      if (a[i] != 0) return false;
    }
    return true;
  } else {
    Frac b(a2, a1);
    for (int i = 3; i < n; i++) {
      if (!(Frac(a[i], a[i - 1]) == b)) return false;
    }
    return true;
  }
}
int aaa() {
  if (n == 1) return 0;
  int zero = 0;
  for (int i = 0; i < n; i++)
    if (a[i] == 0) zero++;
  if (zero == n) return 0;
  if (a[0] == 0) {
    if (n == 2) return 1;
    if (a[1] == 0) {
      int c = 0;
      for (int i = 2; i < n; i++) {
        if (a[i] != 0) {
          c++;
        }
      }
      if (c == 1) return 1;
      return 2;
    }
    Frac b(a[2], a[1]);
    for (int i = 3; i < n; i++) {
      if (!(Frac(a[i], a[i - 1]) == b)) return 2;
    }
    return 1;
  } else {
    if (n == 2) return 0;
    int c = 0;
    if (a[1] == 0) {
      for (int i = 2; i < n; i++) {
        if (a[i] != 0) {
          c++;
        }
      }
    } else {
      double b = (double)a[1] / a[0];
      for (int i = 2, j = 1; i < n;) {
        if (fabs((double)a[i] / a[j] - b) > 1e-8) {
          i++;
          c++;
        } else {
          j = i++;
        }
        if (c == 2) break;
      }
    }
    if (c <= 1) return c;
    if (check(a[1], a[2])) return 1;
    if (check(a[0], a[2])) return 1;
    return 2;
  }
}
void york() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", a + i);
  printf("%d\n", aaa());
}
int main() {
  york();
  return 0;
}
