Doubt in Counting Sort

Despite passing the test case, it is showing that compiler gives run-error
Code https://ide.codingblocks.com/s/118227

@ratulhans hey rahul your code is failling to handle some situation
like
5
1 2 1 2 3
your output is 1 1 2 2
5
1 2 3 2 1
your output is
1 2 2 3
5
1 2 1 2 1
your output is 1 1 2
please optimise your code.