#include <bits/stdc++.h>
int a[100000], b[100000];
bool check(int n) {
  for (int i = 1; i + 1 < n; i++)
    if (a[i] * a[i] != a[i - 1] * a[i + 1]) return 0;
  if (n > 1 && !a[n - 2] && a[n - 1]) return 0;
  return 1;
}
bool check2(int n) {
  for (int i = 0; i < n; i++) b[i] = a[i];
  for (int i = 1; i + 1 < n; i++)
    if (b[i] * b[i] != b[i - 1] * b[i + 1]) {
      for (int j = 0; j <= i; j++) a[j] = b[j];
      for (int j = i + 2; j < n; j++) a[j - 1] = b[j];
      if (check(n - 1)) return 1;
      for (int j = 0; j < i; j++) a[j] = b[j];
      for (int j = i + 1; j < n; j++) a[j - 1] = b[j];
      if (check(n - 1)) return 1;
      for (int j = 0; j < i - 1; j++) a[j] = b[j];
      for (int j = i; j < n; j++) a[j - 1] = b[j];
      if (check(n - 1)) return 1;
      return 0;
    }
  return 1;
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", &a[i]);
  if (check(n))
    puts("0");
  else if (check2(n))
    puts("1");
  else
    puts("2");
  return 0;
}
