Getting WA for CHEFCH (Chef and chain)

Can anyone tell me what’s wrong with my program’s output? It is giving the right output.
http://www.codechef.com/viewsolution/6229821

Your program gives wrong result for this => " ±±±+±±±±-± ". It gives 10 but correct answer is 8.