#include <bits/stdc++.h>
int a[100050];
int main(void) {
  double now, k;
  int last;
  int i;
  int n, tot = 0;
  scanf("%d", &n);
  for (i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    if (a[i] == 0) ++tot;
  }
  if (tot == n) {
    printf("0\n");
    return 0;
  }
  if (tot == n - 1 && tot) {
    if (a[1] != 0)
      printf("0\n");
    else
      printf("1\n");
    return 0;
  }
  if (tot == n - 2 && tot) {
    if (a[1])
      printf("1\n");
    else
      printf("2\n");
    return 0;
  }
  if (tot > 1) {
    printf("2\n");
    return 0;
  }
  if (tot == 1) {
    k = -98999999;
    last = -98999999;
    for (i = 1; i <= n; i++) {
      if (a[i] != 0) {
        if (last == -98999999)
          last = a[i];
        else {
          now = (double)a[i] / last;
          if (k == -98999999)
            k = now;
          else if (k != now)
            break;
          last = a[i];
        }
      }
    }
    if (i == n + 1)
      printf("1\n");
    else
      printf("2\n");
    return 0;
  }
  k = -98999999;
  last = -98999999;
  for (i = 1; i <= n; i++) {
    if (last == -98999999)
      last = a[i];
    else {
      now = (double)a[i] / last;
      if (k == -98999999)
        k = now;
      else if (k != now)
        break;
      last = a[i];
    }
  }
  if (i == n + 1) {
    printf("0\n");
    return 0;
  }
  k = -98999999;
  last = -98999999;
  tot = 0;
  for (i = 1; i <= n; i++) {
    if (last == -98999999)
      last = a[i];
    else {
      now = (double)a[i] / last;
      if (k == -98999999) {
        k = now;
        last = a[i];
      } else if (k != now) {
        ++tot;
        if (tot > 1) break;
      } else
        last = a[i];
    }
  }
  if (i == n + 1) {
    printf("1\n");
    return 0;
  }
  k = -98999999;
  last = -98999999;
  for (i = 2; i <= n; i++) {
    if (last == -98999999)
      last = a[i];
    else {
      now = (double)a[i] / last;
      if (k == -98999999)
        k = now;
      else if (k != now)
        break;
      last = a[i];
    }
    if (i == n) {
      printf("1\n");
      return 0;
    }
  }
  printf("2\n");
  return 0;
}
