#C14634. Find Duplicates in an Array
Find Duplicates in an Array
Find Duplicates in an Array
Given an array of n integers, your task is to identify all the numbers that appear more than once in the array. The duplicates must be printed in the order they first appear in the input.
A number is considered a duplicate if its frequency satisfies \(count(x) \geq 2\). If there are no duplicates, output an empty line.
inputFormat
The input consists of two lines. The first line contains a single integer n — the number of elements in the array. The second line contains n space-separated integers representing the elements of the array.
outputFormat
Output a single line containing the duplicate numbers separated by a single space in the order of their first occurrence. If no duplicate exists, output an empty line.
## sample8
10 20 20 30 30 30 40 40
20 30 40
</p>