#P10426. Mystical Gems in the Enchanted Forest

    ID: 12437 Type: Default 1000ms 256MiB

Mystical Gems in the Enchanted Forest

Mystical Gems in the Enchanted Forest

Deep in a mysterious forest lives a little sprite named Xiao Lan. One day, Xiao Lan discovered a treasure hidden inside a tree hollow, filled with dazzling gems of various colors and shapes. What makes these gems truly special is their unique luminance attribute. Each gem has an intrinsic ability to emit a flash of light with a particular intensity. In total, Xiao Lan found ( n ) gems, and the ( i)th gem has a luminance value of ( H_i ). Xiao Lan plans to select three gems from these ( n ) gems to form a combination. The elegance ( S ) of the combination is measured by the following formula:

[ S = H_a \cdot H_b \cdot H_c \cdot \frac{\operatorname{LCM}(H_a, H_b, H_c)}{\operatorname{LCM}(H_a, H_b) \cdot \operatorname{LCM}(H_a, H_c) \cdot \operatorname{LCM}(H_b, H_c)} ]

where ( \operatorname{LCM} ) denotes the least common multiple. It can be shown that the expression simplifies to the greatest common divisor (GCD) of the three numbers, i.e.,

[ S = \gcd(H_a, H_b, H_c). ]

Your task is to help Xiao Lan choose three gems so that ( S ) is maximized. If there are several combinations that yield the same maximum ( S ) value, choose the one which, when the selected gems' luminance values are sorted in ascending order, is lexicographically smallest.

inputFormat

The first line contains an integer \( n \) (\( n \ge 3 \)), the number of gems.

The second line contains \( n \) space-separated positive integers \( H_1, H_2, \ldots, H_n \), representing the luminance of each gem.

outputFormat

Output three space-separated integers corresponding to the selected gems' luminance values in ascending order.

sample

3
2 4 8
2 4 8