WA in CHN16F

problem link:

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

just increase the size of array a,i made it of size 10^6 and it passed
your solution:CodeChef: Practical coding for everyone

can somebody help me out with the error in my solution…thanks in advance:)