#C8535. Unique Array Elements

    ID: 52528 Type: Default 1000ms 256MiB

Unique Array Elements

Unique Array Elements

Given an array of integers, you are to output the list of unique elements in the order of their first occurrence. This problem requires you to remove duplicates while maintaining the original order in which the numbers first appear.

Formally, given an integer \( n \) and an array \( A = [a_1, a_2, \dots, a_n] \), you need to construct a new array \( B \) such that each element in \( B \) appears only once and in the same order as they first appear in \( A \). For example, if \( A = [4, 5, 6, 5, 4] \), then \( B = [4, 5, 6] \>.

inputFormat

The input consists of two lines:

  1. The first line contains an integer \( n \) representing the number of elements in the array.
  2. The second line contains \( n \) space-separated integers.

outputFormat

Output the unique elements in one line separated by a single space, in the order of their first occurrence.

## sample
5
4 5 6 5 4
4 5 6

</p>