#include <bits/stdc++.h>
using namespace std;
bool geometrica(vector<int> &v) {
  if (int(v.size()) <= 1) return true;
  if (v[0] == 0) {
    for (int i = 1; i < int(v.size()); i++)
      if (v[i] != 0) return false;
    return true;
  }
  for (int i = 2; i < int(v.size()); i++)
    if (v[i] * v[0] != v[i - 1] * v[1]) return false;
  return true;
}
vector<int> borra(vector<int> &v, int index) {
  vector<int> w;
  for (int i = 0; i < int(v.size()); i++)
    if (i != index) w.push_back(v[i]);
  return w;
}
int main() {
  int n;
  cin >> n;
  vector<int> v(n);
  for (int i = 0; i < n; i++) cin >> v[i];
  if (geometrica(v)) {
    cout << 0 << endl;
    exit(0);
  }
  if (n <= 2) {
    cout << 1 << endl;
    exit(0);
  }
  vector<int> w;
  w = borra(v, 0);
  if (geometrica(w)) {
    cout << 1 << endl;
    exit(0);
  }
  w = borra(v, 1);
  if (geometrica(w)) {
    cout << 1 << endl;
    exit(0);
  }
  if (v[0] == 0) {
    int numno0 = 0;
    for (int i = 1; i < n; i++)
      if (v[i] != 0) numno0++;
    if (numno0 >= 2)
      cout << 2 << endl;
    else
      cout << 1 << endl;
    exit(0);
  }
  int numfallos = 0;
  int fallo = -1;
  for (int i = 2; i < int(v.size()); i++) {
    if ((fallo != i - 1 and v[i] * v[0] != v[i - 1] * v[1]) or
        (fallo == i - 1 and v[i] * v[0] != v[i - 2] * v[1])) {
      fallo = i;
      numfallos++;
      if (numfallos >= 2) {
        cout << 2 << endl;
        exit(0);
      }
    }
  }
  cout << 1 << endl;
}
