#include <bits/stdc++.h>
using namespace std;
const int maxn = 100000 + 10;
int seq[maxn], bk[maxn], n;
bool check() {
  if (n - 1 <= 2) return true;
  for (int i = 1; i < n - 2; i++)
    if (bk[i - 1] * bk[i + 1] != bk[i] * bk[i] || bk[i] == 0 && bk[i + 1] != 0)
      return false;
  return true;
}
int solve() {
  if (n < 2) return 0;
  if (n == 2) {
    if (seq[0] == 0 && seq[1] != 0) return 1;
    return 0;
  }
  int p;
  for (p = 1; p < n - 1; p++)
    if (seq[p - 1] * seq[p + 1] != seq[p] * seq[p] ||
        seq[p] == 0 && seq[p + 1] != 0)
      break;
  if (p == n - 1) return 0;
  copy(seq, seq + p - 1, bk);
  copy(seq + p, seq + n, bk + p - 1);
  if (check()) return 1;
  bk[p - 1] = seq[p - 1];
  if (check()) return 1;
  bk[p] = seq[p];
  if (check()) return 1;
  return 2;
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", &seq[i]);
  cout << solve() << endl;
  return 0;
}
