Doubt in a question

I am solving this question from codeforces…
https://codeforces.com/problemset/problem/1407/A
This is my solution…
It is showing wrong answer in test case-3…
This is my solution…
https://codeforces.com/contest/1407/submission/95706517
Can’t figure it out where i am wrong…
Please see this…

hello @ashishnnnnn
what u r trying to do bro.

btw here is the simple approach for this problem
image