My code not passing the test cases

try for this test case:
1
10
305 213 915 543 331 259 751 387 229 949

Expected output is:
305 259 305 424 331 318 331 359 331 359
Yours is giving is:
305 259 305 610 318 331 318 305 318 305
Take reference from this:

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.