#C12818. Find Duplicates in a List

    ID: 42287 Type: Default 1000ms 256MiB

Find Duplicates in a List

Find Duplicates in a List

You are given a list of integers. Your task is to find all the integers that appear more than once in the list, and output them in sorted order.

The input starts with an integer \(n\) representing the number of elements, followed by \(n\) space-separated integers. The output should be a space-separated list of duplicate integers in ascending order. If no duplicates are found, output an empty line.

Example

Input:
8
4 3 2 7 8 2 3 1

Output: 2 3

</p>

Note: The problem may involve large input sizes, so make sure your solution is efficient enough.

inputFormat

The input is given through standard input and includes:

  • An integer \(n\) indicating the number of integers.
  • A line with \(n\) space-separated integers.

\(1 \leq n \leq 10^5\) and each integer is in the range \(1 \leq x \leq 10^9\).

outputFormat

Output the sorted list of integers that appear more than once. The integers should be printed on one line separated by a single space. If there are no duplicates, print an empty line.

## sample
8
4 3 2 7 8 2 3 1
2 3