Spoj giving me runtime error (NZEC) for CANDY - Candy I problem.

I am trying to code a simple problem in java available here

My approach to solve it is , get the number of candy packets in count variable and number of candies in each packet in a array.

My code is below , I have explained the code in comments :

It is compiling and running properly in Ideone , but giving me a runtime error (NZEC) in Spoj.

please figure out what is wrong in it.
If possible , please review my code and give me some suggestion about the code I have written.