#ARC158B. [ARC158B] Sum-Product Ratio

[ARC158B] Sum-Product Ratio

Score : 500500 points

Problem Statement

You are given non-zero integers x1,,xNx_1, \ldots, x_N. Find the minimum and maximum values of xi+xj+xkxixjxk\dfrac{x_i+x_j+x_k}{x_ix_jx_k} for integers ii, jj, kk such that 1i<j<kN1\leq i < j < k\leq N.

Constraints

  • 3N2×1053\leq N\leq 2\times 10^5
  • 106xi106-10^6\leq x_i \leq 10^6
  • xi0x_i\neq 0

Input

The input is given from Standard Input in the following format:

NN

x1x_1 \ldots xNx_N

Output

Print the minimum value of xi+xj+xkxixjxk\dfrac{x_i+x_j+x_k}{x_ix_jx_k} in the first line and the maximum value in the second line.

Your output will be considered correct when the absolute or relative error is at most 101210^{-12}.

4
-2 -4 4 5
-0.175000000000000
-0.025000000000000

xi+xj+xkxixjxk\dfrac{x_i+x_j+x_k}{x_ix_jx_k} can take the following four values.

  • (i,j,k)=(1,2,3)(i,j,k) = (1,2,3): $\dfrac{(-2) + (-4) + 4}{(-2)\cdot (-4)\cdot 4} = -\dfrac{1}{16}$.
  • (i,j,k)=(1,2,4)(i,j,k) = (1,2,4): $\dfrac{(-2) + (-4) + 5}{(-2)\cdot (-4)\cdot 5} = -\dfrac{1}{40}$.
  • (i,j,k)=(1,3,4)(i,j,k) = (1,3,4): $\dfrac{(-2) + 4 + 5}{(-2)\cdot 4\cdot 5} = -\dfrac{7}{40}$.
  • (i,j,k)=(2,3,4)(i,j,k) = (2,3,4): $\dfrac{(-4) + 4 + 5}{(-4)\cdot 4\cdot 5} = -\dfrac{1}{16}$.

Among them, the minimum is 740-\dfrac{7}{40}, and the maximum is 140-\dfrac{1}{40}.

4
1 1 1 1
3.000000000000000
3.000000000000000
5
1 2 3 4 5
0.200000000000000
1.000000000000000