Removing duplicates while preserving order

PHP Medium arrays

Task «Removing duplicates while preserving order»

Write a program that takes an array of integers and removes all duplicates from it, preserving the original order of elements. The program should output a new array containing only unique elements in the order they appear in the original array. Additionally, if the number of unique elements is less than 3, the program should output the message 'Too few unique elements'. Constraints: the size of the input array does not exceed 1000, the elements are integers from -10^9 to 10^9.

Input Format

In the first line, an integer N (1 ≤ N ≤ 1000) — the number of elements in the array. In the second line, N integers separated by spaces.

Output Format

Output the unique elements of the array, separated by spaces, in the order of their first occurrence. If the number of unique elements is less than 3, output 'Too few unique elements'.

Examples

Example 1

INPUT
5 1 2 2 3 1
OUTPUT
1 2 3

Example 2

INPUT
3 Война и мир Толстой 1869 Преступление и наказание Достоевский 1866 Анна Каренина Толстой 1877 1866
OUTPUT
Преступление и наказание

Example 3

INPUT
3 10 10 10
OUTPUT
Мало уникальных элементов

Example 4

INPUT
2 Мастер и Маргарита Булгаков 1967 Тихий Дон Шолохов 1940 2000
OUTPUT
Нет
main.php