#include <bits/stdc++.h>
int in[100010];
int min(int a, int b) { return a > b ? b : a; }
int main() {
  int i, j, k, n, p, ans;
  double d;
  scanf("%d", &n);
  for (i = 1; i <= n; i++) {
    scanf("%d", &in[i]);
  }
  if (n == 1) {
    printf("0\n");
    return 0;
  }
  if (n == 2) {
    if (!in[1] && in[2])
      printf("1\n");
    else
      printf("0\n");
    return 0;
  }
  ans = 2;
  for (i = 1; i <= 2; i++)
    for (j = i + 1; j <= 3; j++) {
      if (!in[i] && in[j]) continue;
      if (in[i] == 0)
        d = 0;
      else
        d = (double)in[j] / in[i];
      p = j;
      int s = 0;
      if (i != 1 || j != 2) s++;
      for (k = j + 1; k <= n; k++)
        if (fabs(in[p] * d - in[k]) < 1e-9)
          p = k;
        else
          s++;
      ans = min(ans, s);
    }
  printf("%d\n", ans);
  return 0;
}
