Agreesive cows problem

where am i going wrong?

Sort the array after taking input.