SPOJ PICAD WA

Can anyone point out the mistake in the algorithm??