#C4068. Remove Duplicates from a List

    ID: 47565 Type: Default 1000ms 256MiB

Remove Duplicates from a List

Remove Duplicates from a List

Given a list of integers, your task is to remove the duplicate elements while preserving the order of their first occurrence. Formally, let (A = [a_1, a_2, \dots, a_n]) be the input list. You must produce a list (B) such that each element in (B) appears in (A) in the same order, and every element in (B) is unique.

For example, if (A = [1, 3, 3, 7, 8, 8, 9]), then the resulting list should be (B = [1, 3, 7, 8, 9]).

inputFormat

The input consists of two lines.

The first line contains a single integer (n), representing the number of elements in the list.

The second line contains (n) space-separated integers. It is guaranteed that (n \ge 0).

outputFormat

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

7
1 3 3 7 8 8 9
1 3 7 8 9