Correct code still wrong output

The code is correct. when the custom input is copy-pasted from the question the output shown is wrong when the same input is typed the output shown is right. Why is this happening for the same n correct code?