#C10452. Unique Elements Extraction

    ID: 39659 Type: Default 1000ms 256MiB

Unique Elements Extraction

Unique Elements Extraction

In this problem, you are given a list of integers. Your task is to extract the unique elements from the list while preserving the order of their first appearance. Formally, given an integer ( n ) and a list of integers ( a_1, a_2, \dots, a_n ), you need to output a list ( b_1, b_2, \dots, b_k ) such that each element appears only once and in the same relative order as in the original list.

For example, if the list is [1, 2, 2, 3, 4, 4, 5], the unique elements in order are [1, 2, 3, 4, 5].

inputFormat

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

outputFormat

Output a single line containing the unique elements extracted from the list in their original order, separated by a single space. If the list is empty, output an empty line.## sample

7
1 2 2 3 4 4 5
1 2 3 4 5