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>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma comment(linker, "/stack:200000000")
using namespace std;
long long spf[101];
long long fac[101];
void sieve() {
  spf[1] = 1;
  for (long long i = 2; i < 101; i++) spf[i] = i;
  for (long long i = 4; i < 101; i += 2) spf[i] = 2;
  for (long long i = 3; i * i < 101; i++) {
    if (spf[i] == i) {
      for (long long j = i * i; j < 101; j += i)
        if (spf[j] == j) spf[j] = i;
    }
  }
}
map<long long, long long> getfactor(long long a) {
  map<long long, long long> m;
  while (a > 1) {
    m[spf[a]]++;
    a /= spf[a];
  }
  return m;
}
long long power(long long x, long long y, long long p) {
  long long res = 1;
  x = x % p;
  if (x == 0 || y < 0) return 0;
  while (y > 0) {
    if (y & 1) res = (res * x) % p;
    y = y >> 1;
    x = (x * x) % p;
  }
  return res;
}
long long gcd(long long a, long long b) {
  if (a == 0) return b;
  return gcd(b % a, a);
}
long long inverse(long long a, long long p) { return power(a, p - 2, p); }
long long ncr(long long n, long long r, long long p) {
  if (r > n) return 0;
  if (r == 0 || r == n) return 1;
  return (fac[n] * inverse(fac[r], p) % p * inverse(fac[n - r], p) % p) % p;
}
void solve() {
  long long n;
  cin >> n;
  if (n == 1) {
    cout << 0 << '\n';
    return;
  }
  long double a[n + 1];
  long long ct = 0;
  for (long long i = 1; i <= n; i++) cin >> a[i], ct += (a[i] == 0);
  if (ct == n) {
    cout << 0 << '\n';
    return;
  } else if (ct == n - 1 && (a[1] != 0)) {
    cout << 0 << '\n';
    return;
  } else if (ct == n - 1) {
    cout << 1 << '\n';
    return;
  } else if (ct == n - 2 && n > 2) {
    if (a[1] != 0) {
      cout << 1 << '\n';
      return;
    }
  }
  long double suff[n + 5], pre[n + 5];
  if (a[1] != 0)
    pre[2] = a[2] / a[1];
  else
    pre[2] = -1e18;
  for (long long i = 3; i <= n; i++) {
    if (a[i - 1] != 0)
      pre[i] = a[i] / a[i - 1];
    else
      pre[i] = -1e18;
    if (pre[i] != pre[i - 1]) pre[i] = -1e18;
  }
  if (a[n - 1] != 0)
    suff[n - 1] = a[n] / a[n - 1];
  else
    suff[n - 1] = -1e18;
  for (long long i = n - 2; i >= 1; i--) {
    if (a[i] != 0)
      suff[i] = a[i + 1] / a[i];
    else
      suff[i] = -1e18;
    if (suff[i] != suff[i + 1]) suff[i] = -1e18;
  }
  pre[1] = suff[3];
  suff[n] = pre[n - 2];
  if (pre[n] != -1e18) {
    cout << 0 << '\n';
    return;
  }
  for (long long i = 2; i < n; i++) {
    if (a[i - 1] != 0 && pre[i - 1] == suff[i + 1] &&
        a[i + 1] / a[i - 1] == pre[i - 1] && pre[i - 1] != -1e18) {
      cout << 1 << '\n';
      return;
    }
  }
  for (long long i = 3; i <= n; i++) {
    if (a[i - 1] != 0)
      pre[i] = a[i] / a[i - 1];
    else
      pre[i] = -1e18;
    if (i == 3) pre[i - 1] = pre[i];
    if (pre[i] != pre[i - 1]) pre[i] = -1e18;
  }
  if (pre[n] != -1e18) {
    cout << 1 << '\n';
    return;
  }
  for (long long i = n - 2; i >= 1; i--) {
    if (a[i] != 0)
      suff[i] = a[i + 1] / a[i];
    else
      suff[i] = -1e18;
    if (i == n - 2) suff[i + 1] = suff[i];
    if (suff[i] != suff[i + 1]) suff[i] = -1e18;
  }
  if (suff[1] != -1e18) {
    cout << 1 << '\n';
    return;
  }
  for (long long i = n - 1; i >= 2; i--) {
    if (a[i + 1] != 0)
      suff[i] = a[i] / a[i + 1];
    else
      suff[i] = -1e18;
    if (i == n - 1) suff[i + 1] = suff[i];
    if (suff[i] != suff[i + 1]) suff[i] = -1e18;
  }
  if (suff[2] != -1e18) {
    cout << 1 << '\n';
    return;
  }
  for (long long i = 2; i < n; i++) {
    if (a[i] != 0)
      pre[i] = a[i - 1] / a[i];
    else
      pre[i] = -1e18;
    if (i == 2) pre[i - 1] = pre[i];
    if (pre[i] != pre[i - 1]) pre[i] = -1e18;
  }
  if (pre[n - 1] != -1e18) {
    cout << 1 << '\n';
    return;
  }
  cout << min(2ll, n - 1) << '\n';
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long t = 1;
  while (t--) {
    solve();
  }
}
