Getting WA in Chef and Rainbow Array - 2

My code is giving correct answer i’ve checked using brute force approach up to 100 but i don’t know why judge is giving me wrong answer for Chef and Rainbow Array - 2.

Ongoing contest question cannot be helped right now!

Hi Niraj, Kindly avoid posting questions related to problems from ongoing contest. If you have any doubts, you can always write to us or can post your queries in the comment section of the problem.