public static void main(String[] args) throws IOException{ BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); int n = Integer.parseInt(reader.readLine()); Map<Integer, Integer> map = new TreeMap<>(); for(int i = 0; i < n; i++)...