#K8106. Build the Largest Pyramid of Fruits

    ID: 35669 Type: Default 1000ms 256MiB

Build the Largest Pyramid of Fruits

Build the Largest Pyramid of Fruits

Given an array of integers representing the sweetness levels of fruits, build the largest possible pyramid. The pyramid is constructed by selecting unique fruits such that the sequence is strictly decreasing, i.e. each fruit has a lower sweetness level than the one above it.

In mathematical terms, if the set of unique sweetness levels is \(S\), you must output the sequence \(p_1, p_2, \ldots, p_k\) such that \(p_1 > p_2 > \cdots > p_k\) and \(S = \{p_1, p_2, \ldots, p_k\}\).

For example, given the array [3, 3, 1, 1, 2, 2], the largest pyramid is [3, 2, 1].

inputFormat

The first line contains an integer \(n\) denoting the number of fruits. The second line contains \(n\) space-separated integers representing the sweetness levels of the fruits.

outputFormat

Output a single line containing the elements of the pyramid, which are the unique sweetness levels in strictly decreasing order, separated by a single space.

## sample
6
3 3 1 1 2 2
3 2 1