#C13020. Unique Elements Preservation

    ID: 42513 Type: Default 1000ms 256MiB

Unique Elements Preservation

Unique Elements Preservation

Given a sequence of integers, remove all duplicate occurrences while preserving the order of their first appearance. More formally, if the input is a list of integers \( a_1, a_2, \ldots, a_n \), output a list \( b_1, b_2, \ldots, b_k \) such that:

[ {b_1, b_2, \ldots, b_k} = {a_1, a_2, \ldots, a_n} \quad \text{and} \quad b_i \text{ appears before } b_j \text{ in the output if its first occurrence in the input is earlier} ]

The input is provided via standard input and the answer must be printed to standard output.

inputFormat

The first line contains a single integer \( n \) which denotes the number of elements in the list. The second line contains \( n \) space-separated integers.

outputFormat

Output the unique elements in a single line, separated by a single space, in the order that they first appeared in the input.

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