#include <bits/stdc++.h>
using namespace std;
const int maxN = 100000 + 5;
int n;
int a[maxN];
inline bool isGeo(int *s, int *e) {
  int len = e - s;
  if (len == 1) return true;
  if (s[1] == 0) {
    for (int i = 1; i <= len; i++)
      if (s[i] != 0) return false;
    return true;
  }
  for (int i = 3; i <= len; i++)
    if (s[i] * s[1] != s[i - 1] * s[2]) {
      return false;
    }
  return true;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  if (isGeo(a, a + n)) {
    puts("0");
    return 0;
  }
  if (isGeo(a + 1, a + n)) {
    puts("1");
    return 0;
  }
  if (a[1] == 0) {
    int no0 = 0;
    for (int i = 2; i <= n; i++)
      if (a[i] != 0) no0++;
    if (no0 == 1)
      puts("1");
    else
      puts("2");
    return 0;
  }
  swap(a[1], a[2]);
  if (isGeo(a + 1, a + n)) {
    puts("1");
    return 0;
  }
  swap(a[1], a[2]);
  int cnt = 2, end = a[2];
  for (int i = 3; i <= n; i++)
    if (a[i] * a[1] == end * a[2]) {
      cnt++;
      end = a[i];
    }
  if (cnt == (n - 1))
    puts("1");
  else
    puts("2");
  return 0;
}
