Function to return the count the number of possible arrays mod P of length K such that the product of all elements of that array is equal to the product of all elements of the given array of length N
public static long countArrays ( long [ ] arr , long N , long K , long P ) {