Chef in Queue : DSA Learning Series

Hi I have been trying to solve Chef In Queue problem from DSA learning series Questionand I am not sure why my solution is wrong. Can anyone please help me explain what am I missing here? ThanksMy solution

public static void main (String[] args) throws java.lang.Exception
	{
		// your code goes here
		FastReader fr = new FastReader();
		int N = fr.nextInt();
		long M = 1000000007;
		int K = fr.nextInt();
		long f = 1;
		int[] arr = new int[N];
		arr[0] = 0;
		for(int i = 1 ; i < N ; i++){
		    arr[i] = fr.nextInt();
		}
		for (int i = 1; i < N; i++)
    {
        int j;
        for(j = i - 1; j >= 0; j--)
        {
            if (arr[j] < arr[i])
            {
                f = (f *(j - i + 1)) % M;
                break;
            }
        }
		System.out.println(f);
    }
}