Polycarp loves geometric progressions — he collects them. However, as such progressions occur very rarely, he also loves the sequences of numbers where it is enough to delete a single element to get a geometric progression.

In this task we shall define geometric progressions as finite sequences of numbers a1, a2, ..., ak, where ai = c·bi - 1 for some real numbers c and b. For example, the sequences [2, -4, 8], [0, 0, 0, 0], [199] are geometric progressions and [0, 1, 2, 3] is not.

Recently Polycarp has found a sequence and he can't classify it. Help him to do it. Determine whether it is a geometric progression. If it is not, check if it can become a geometric progression if an element is deleted from it.

Input

The first line contains an integer n (1 ≤ n ≤ 105) — the number of elements in the given sequence. The second line contains the given sequence. The numbers are space-separated. All the elements of the given sequence are integers and their absolute value does not exceed 104.

Output

Print 0, if the given sequence is a geometric progression. Otherwise, check if it is possible to make the sequence a geometric progression by deleting a single element. If it is possible, print 1. If it is impossible, print 2.

Examples

Input

4
3 6 12 24


Output

0


Input

4
-8 -16 24 -32


Output

1


Input

4
0 1 2 3


Output

2
import java.util.*;
import java.math.*;
import static java.lang.Character.isDigit;
import static java.lang.Character.isLowerCase;
import static java.lang.Character.isUpperCase;
import static java.lang.Math.*;
import static java.math.BigInteger.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
import static java.lang.Character.isDigit;

public class Main{
    static void debug(Object...os){
        System.err.println(deepToString(os));
    }
    void run(){
        int n=nextInt();
        int[] as=new int[n];
        for(int i=0;i<n;i++)as[i]=nextInt();
        System.out.println(solve(as));
    }
    
    double EPS = 1e-7;
    boolean zero(int[] as) {
        int n = as.length;
        if(n==1)return true;
        if(as[0]==0) {
            for(int i=0;i<n;i++)if(as[i]!=0)return false;
            return true;
        }
        if(n==2)return true;
        double d = (double)as[1]/as[0];
        for(int i=0;i<n-1;i++) {
            if(abs(as[i]*d-as[i+1])>EPS)return false;
        }
        return true;
    }
    boolean one(int[] as) {
        int n=as.length;
        int[] bs=new int[n-1];
        for(int i=0;i<n-1;i++)bs[i] = as[i+1];
        if(zero(bs))return true;
        bs[0]=as[0];
        for(int i=2;i<n;i++)bs[i-1]=as[i];
        if(zero(bs))return true;
        
        if(as[0]==0) {
            int cnt=0;
            for(int i=0;i<n;i++)if(as[i]!=0)cnt++;
            assert cnt!=0;
            return cnt<=1;
        }
        
        double d = (double)as[1]/as[0];
        for(int i=0;i<n-1;i++) {
            if(abs(as[i]*d-as[i+1])>EPS) {
                for(int j=0;j<=i;j++)bs[j]=as[j];
                for(int j=i+2;j<n;j++)bs[j-1]=as[j];
                return zero(bs);
            }
        }
        assert false;
        return false;
    }
    
    int solve(int[] as) {
        if(zero(as))return 0;
        if(one(as))return 1;
        return 2;
    }
    
    int nextInt(){
        try{
            int c=System.in.read();
            if(c==-1) return c;
            while(c!='-'&&(c<'0'||'9'<c)){
                c=System.in.read();
                if(c==-1) return c;
            }
            if(c=='-') return -nextInt();
            int res=0;
            do{
                res*=10;
                res+=c-'0';
                c=System.in.read();
            }while('0'<=c&&c<='9');
            return res;
        }catch(Exception e){
            return -1;
        }
    }
    
    long nextLong(){
        try{
            int c=System.in.read();
            if(c==-1) return -1;
            while(c!='-'&&(c<'0'||'9'<c)){
                c=System.in.read();
                if(c==-1) return -1;
            }
            if(c=='-') return -nextLong();
            long res=0;
            do{
                res*=10;
                res+=c-'0';
                c=System.in.read();
            }while('0'<=c&&c<='9');
            return res;
        }catch(Exception e){
            return -1;
        }
    }
    
    double nextDouble(){
        return Double.parseDouble(next());
    }
    
    String next(){
        try{
            StringBuilder res=new StringBuilder("");
            int c=System.in.read();
            while(Character.isWhitespace(c))
                c=System.in.read();
            do{
                res.append((char)c);
            }while(!Character.isWhitespace(c=System.in.read()));
            return res.toString();
        }catch(Exception e){
            return null;
        }
    }
    
    String nextLine(){
        try{
            StringBuilder res=new StringBuilder("");
            int c=System.in.read();
            while(c=='\r'||c=='\n')
                c=System.in.read();
            do{
                res.append((char)c);
                c=System.in.read();
            }while(c!='\r'&&c!='\n');
            return res.toString();
        }catch(Exception e){
            return null;
        }
    }
    public static void main(String[] args){
        new Main().run();
    }
}
