wrong ans in CHEFA

I tried this code in the IDE and was getting the write ans. Got wrong in the contest. Whats the mistake?http://www.codechef.com/viewsolution/4915829

try long int instead of int

range of numbers: 1<=a[i]<=10^9

I tried using long also. Still getting wrong answer.

try using long long int,instead of long.