SGARDEN wrong answer

link of my solution http://www.codechef.com/viewsolution/4337629
getting wrong answer

ans*=j*p[j]; // this can overflow.

You need to take modulo at each intermediate step.