WA in SPOJ SUMITR

,

I am trying to solve the following problem:

http://www.spoj.com/problems/SUMITR/

I keep on getting WA but I am unable to find my error. Here’s my solution:

http://ideone.com/AlWDvz

Please help me in finding out what I am doing wrong.