#P8636. Determine the Maximum Geometric Ratio

    ID: 21802 Type: Default 1000ms 256MiB

Determine the Maximum Geometric Ratio

Determine the Maximum Geometric Ratio

On planet X, a grand contest awards prizes in M different levels. The prize for each level is a positive integer, and the ratio between any two consecutive levels is fixed. In other words, the M prizes form a geometric progression. For example, the sequence

(16,,24,,36,,54)

has a common ratio (\frac{3}{2}) because (16 \times \frac{3}{2} = 24), (24 \times \frac{3}{2} = 36) and (36 \times \frac{3}{2} = 54).

We have randomly collected all M prize values (though not necessarily given in order). Your task is to compute the common ratio of the prizes in its simplest fraction form. It is guaranteed that the input prizes do form a valid geometric progression and that the maximum possible ratio (which is unique) can be written as a simplified fraction (\frac{p}{q}) with (p,q) coprime (and (q>0)).

Note: If the prizes are given as

(A,,A,r,,A,r^2,,\dots,,A,r^{M-1}),

then we have

[ r^{M-1} = \frac{\max{\text{prizes}}}{\min{\text{prizes}}}. ]

Thus the common ratio is

[ r = \Biggl(\frac{\max{\text{prizes}}}{\min{\text{prizes}}}\Biggr)^{1/(M-1)}. ]

Since all prizes are integers and the progression is valid, it can be shown that the above expression is a rational number which, when expressed in simplest terms, is the answer.

inputFormat

The first line contains a single integer M (2 ≤ M ≤ 105), the number of prize levels.

The second line contains M positive integers separated by spaces, representing the prize amounts (in arbitrary order). It is guaranteed that these amounts form a geometric progression.

outputFormat

Output the common ratio of the geometric progression in its simplest fraction form as p/q (without spaces), where p and q are coprime positive integers.

sample

4
16 24 36 54
3/2