Fungraph Wrong answer

why my solution is giving me wrong answer ? following editorial approach.
link https://www.codechef.com/viewsolution/9944587