Aggressive Cow Problem

My code is not compatible with the sample test case “https://ide.codingblocks.com/s/345724

sort the array too
add Arrays.sort(arr); in line 14