#include <bits/stdc++.h>
using namespace std;
int n, a[100005];
int main() {
  int i, cnt_zero = 0, lst, cur, nxt, ignore;
  bool flag = true;
  scanf("%d", &n);
  for (i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    if (a[i] == 0) cnt_zero++;
  }
  if (n == 1 || cnt_zero == n || (n == 2 && cnt_zero == 0) ||
      (cnt_zero == n - 1 && a[1] != 0)) {
    printf("0\n");
    return 0;
  }
  if (cnt_zero == n - 1 || (cnt_zero == n - 2 && a[1] != 0)) {
    printf("1\n");
    return 0;
  }
  if (cnt_zero > 1) {
    printf("2\n");
    return 0;
  }
  if (cnt_zero == 1) {
    i = 1;
    while (i <= n && a[i] == 0) i++;
    lst = i, i++;
    while (i <= n && a[i] == 0) i++;
    cur = i, i++;
    while (i <= n && a[i] == 0) i++;
    nxt = i;
    while (nxt <= n) {
      if (a[cur] * a[cur] != a[nxt] * a[lst]) {
        printf("2\n");
        return 0;
      }
      lst = cur, cur = nxt;
      nxt++;
      while (nxt <= n && a[nxt] == 0) nxt++;
    }
    printf("1\n");
    return 0;
  }
  if (n == 3) {
    if (a[2] * a[2] == a[1] * a[3])
      printf("0\n");
    else
      printf("1\n");
    return 0;
  }
  for (i = 1; i <= n - 1; i++) {
    if (i == n - 1) {
      printf("0\n");
      return 0;
    }
    if (a[i + 1] * a[i + 1] != a[i] * a[i + 2]) break;
  }
  for (ignore = 1; ignore <= 2; ignore++) {
    i = 1;
    while (i <= n && i == ignore) i++;
    lst = i, i++;
    while (i <= n && i == ignore) i++;
    cur = i, i++;
    while (i <= n && i == ignore) i++;
    nxt = i;
    while (nxt <= n) {
      if (a[cur] * a[cur] != a[nxt] * a[lst]) break;
      lst = cur, cur = nxt, nxt++;
    }
    if (nxt > n) {
      printf("1\n");
      return 0;
    }
  }
  lst = 1, cur = 2, nxt = 3;
  while (nxt <= n) {
    if (a[cur] * a[cur] != a[nxt] * a[lst]) {
      if (flag) {
        nxt++;
        flag = false;
        continue;
      } else {
        printf("2\n");
        return 0;
      }
    }
    lst = cur, cur = nxt, nxt++;
  }
  printf("1\n");
  return 0;
}
