#K6386. Unique User IDs Filter

    ID: 31847 Type: Default 1000ms 256MiB

Unique User IDs Filter

Unique User IDs Filter

In this problem, you are given a sequence of events represented by integers. Each event corresponds either to a user ID or a system event. The system events are denoted by (-1). Your task is to extract and print the list of unique user IDs in the order of their first appearance, ignoring any system events.

Formally, you are provided with an integer (N) and a sequence of (N) integers (a_1, a_2, \dots, a_N). Your goal is to output the sequence of numbers which are not equal to (-1) such that each number appears only once and in the same order as in the input.

For example, given the input:

9 3 5 3 -1 2 5 -1 3 7

The output should be:

3 5 2 7

inputFormat

The first line contains a positive integer (N) indicating the number of events. The second line contains (N) space-separated integers representing the events.

outputFormat

Output a single line containing the unique user IDs (excluding (-1)) in the order of their first occurrence, separated by a single space. If no valid user IDs exist, output an empty line.## sample

9
3 5 3 -1 2 5 -1 3 7
3 5 2 7

</p>