#C6027. Remove Duplicates from a List

    ID: 49742 Type: Default 1000ms 256MiB

Remove Duplicates from a List

Remove Duplicates from a List

Given a list of integers, your task is to remove all duplicate entries while preserving the order of their first appearance. Formally, if the input list is \(a_1, a_2, \dots, a_n\), you must output a list \(b_1, b_2, \dots, b_k\) such that:

\[ \{b_1, b_2, \dots, b_k\} = \{a_1, a_2, \dots, a_n\}, \]

and for any two indices \(i < j\), the element \(b_i\) appears before \(b_j\) in the input list.

Please write a program that reads input from standard input (stdin) and writes the result to standard output (stdout). The input format is as follows: the first line contains the number of integers \(n\), and the second line contains \(n\) space-separated integers.

inputFormat

The first line of input contains an integer \(n\) representing the number of elements in the list. The second line contains \(n\) space-separated integers.

outputFormat

Output the list after removing duplicates, preserving the order of their first occurrence. The numbers should be printed on a single line separated by a single space. If the resulting list is empty, output an empty line.

## sample
7
1 2 2 3 4 4 5
1 2 3 4 5