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
 
      
    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