#C8890. Remove Duplicates and Preserve Order

    ID: 52922 Type: Default 1000ms 256MiB

Remove Duplicates and Preserve Order

Remove Duplicates and Preserve Order

You are given a list of integers. Your task is to remove all duplicate elements while preserving the original order of the remaining elements.

For example, if the input list is [1, 2, 2, 3, 4, 4, 5], the correct output is [1, 2, 3, 4, 5].

Note: If the list is empty, the output should be empty as well.

The mathematical formulation: Given a list L=[a1,a2,,an]L = [a_1, a_2, \dots, a_n], find the list RR such that each element appears only once and the order is preserved.

inputFormat

The first line of input contains an integer nn, the number of elements in the list. The second line contains nn space-separated integers.

outputFormat

Output a single line containing the list after removing duplicates, with the remaining elements separated by a single space. If the list is empty, output nothing.## sample

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