#C13450. Remove Duplicates While Preserving Order

    ID: 42990 Type: Default 1000ms 256MiB

Remove Duplicates While Preserving Order

Remove Duplicates While Preserving Order

You are given a list of integers. Your task is to remove all duplicate elements from the list while preserving the order of their first appearance. That is, each element should appear in the output only once and in the same order as they first appeared in the input.

Note: The order in which the numbers appear in the output should be the same as in the input.

Example: For an input list [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5], the output should be [3, 1, 4, 5, 9, 2, 6].

inputFormat

The input is read from stdin and 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.

outputFormat

Output to stdout the list after removing duplicates. The numbers should be printed in a single line, separated by a space.

## sample
4
1 2 3 4
1 2 3 4