This code gives wrong output

This code gives wrong outpit for some input
10 2
9 54 33 58 88 45 57 9 95 98 14 53 46 65 71 54 52 2 77 67
check this input

@mayurjhode55 share the code using cb ide