Need Help #PRMDIV problem

problem url https://www.codechef.com/problems/PRMDIV

Can anyone help and chk my solution for above problem I am getting only one input test incorrect and rest all are correct can anyone chk my code and help me??

solution link: https://www.codechef.com/viewsolution/19404205

freq is integer array multiplying 2 of them might cause overflow.

AC code:https://www.codechef.com/submit/complete/19404484

changed it to long freq and got correct but I didn’t got your point if you could elaborate how freq would get overflow if my freq count will always be less than 1000000 and my variable count which multiplies freq is already long.

Read type conversion in JAVA and C++. First, freq[i] is int. Intermediate-Product of 2 int is stored in int. Overflow happens. Then this overflowed result stored in count.